in reply to foreach loop to untar multiple files

system doesn't return the output of the command run, it returns the exit code of what's run, in your case 0 hence the 0 in your output "tar: 0: Cannot open: No such file or directory". Take a look at the glob() perl command to get the listing of files in a directory.