in reply to untarring number of files

Your script doesn't work because you are using single quotes inside system(...), and perl will not expand variables inside single quotes. Change single quotes to double quotes and it will work -

#!/usr/bin/perl -w chomp(my @list=`ls *.tar`); foreach (@list) { system "tar -xvf $_"; }
Note that you don't have to untar a single file at a time, tar is quite happy to accept multiple files at the same time:
#!/usr/bin/perl -w chomp(my @list=`ls *.tar`); system "tar -xvf " . qq{@{[@list]}};
And better still, you don't even need to write a script at all, just type this at the shell prompt:
tar -xvf *.tar
Update: Thanks to sauoq for pointing out my mistake with tar and multiple input files.

Replies are listed 'Best First'.
Re: Re: untarring number of files
by sauoq (Abbot) on Oct 23, 2003 at 06:34 UTC
    Note that you don't have to untar a single file at a time, tar is quite happy to accept multiple files at the same time:

    Uhm... no.

    Arguments after the tarball filename are expected to be files to untar from the tarball. So, that won't work at all. Instead, you'll get an error like "foo.tar: Not found in archive."

    -sauoq
    "My two cents aren't worth a dime.";