in reply to foreach loop to untar multiple files

The problem is that the output of system is the exit value of the ls command, not the output of the ls command. You could use qx to capture the ls command output.

Another approach is to use glob:

my $results = "~/results"; # results coming in. for (glob "$results/*.tar.gz") { system "tar -tvf $_"; }