http://www.perlmonks.org?node_id=828313


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