Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: How to replace spaces with different chars?

by kcott (Archbishop)
on Jul 07, 2022 at 14:05 UTC ( [id://11145331]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11145331]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-23 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found