http://qs321.pair.com?node_id=11145331


in reply to How to replace spaces with different chars?

In my initial response I answered your question about using system; however, it occurs to me that you probably want to capture that output and do something with it. So, if you replace

system("ls -1 $datum");

with

my @matches = `ls -1 $datum`;

you'll now have an array of matches that you can process further. If that processing was

print for @matches;

you'll get identical output to what I originally posted.

— Ken

Replies are listed 'Best First'.
Re^2: How to replace spaces with different chars?
by LanX (Saint) on Jul 07, 2022 at 14:15 UTC
    why not use

    my @matches = glob($datum)

    or

    my @matches = <$datum>

    directly?

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      This was a follow-up to my previous post about system, which has:

      "This is not what you want to use to capture the output from a command; for that you should use merely backticks or qx//, ..."

      Of course, TMTOWTDI. :-)

      — Ken