Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: storing system function output

by doug (Pilgrim)
on Mar 12, 2010 at 14:58 UTC ( #828313=note: print w/replies, xml ) Need Help??


in reply to storing system function output

system doesn't glue in STDIN/STDOUT/STDERR, so you'll have to do that on your own. Generally use the open with a bar (pipe character) to launch programs where you need to capture the output. Try RTFM:

perldoc -f open

I don't think I'd ever launch ls as a child process because it is too easy to get that information on your own. opendir and readdir work will do nearly anything that you need for filenames. And for this particular case, there is a specialised tool for that:

my @files = glob("/path/to/directory/*");

The docs for opendir, readdir, closedir and glob are all in perlfunc so you can use perldoc -f OP to view them.

- doug

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://828313]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2017-12-18 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (501 votes). Check out past polls.

    Notices?