Thank you all, I will be doing the relevant reading (on glob) and modifying the script accordingly.
I've already copied and tried this
my $results = "~/results"; # results coming in. for (glob "$results/*.tar.gz") { system "tar -tvf $_"; }
...and it does what I want.
I've tried the following modification in my script though, and something funny happens again.
foreach (@tar) { `tar -tvf $results\/$_`; }
This gives me the following error:
tar: /home/user/results//home/user/results/results_back.tar.gz: Cannot open: No such file or directory
So the path to the tar.gz file is messed up obviously. But then my hopes build up because I see that it finds the tar.gz file and that's when I stupidly try to be "clever" by removing $results completely from the command and only keeping $_. In that case I'm just getting nothing, it fails quietly. Why is that?
In reply to Re: foreach loop to untar multiple files
by fasoli
in thread foreach loop to untar multiple files
by fasoli
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |