I am learning PERL lang. I have forced (and little confused) the issue with extracting *.tgz files. My point which I want to achieve is to extract multiple *.tgz files to multiple folders.
So the structure comes:
JavaScript
x
first.tgz
sec.tgz
third.tgz
n.tgz
I want to extract these files to directories:
JavaScript
first (extracted first.tgz)
sec (extracted sec.tgz)
thidrd (extracted third.tgz)
etc.
Can someone help me with this, or give some hints how to achieve it?
Advertisement
Answer
With atool:
JavaScript
use autodie qw(:all);
use Path::Tiny qw(path);
for my $archive (qw(first.tgz sec.tgz third.tgz n.tgz)) {
my $basename = path($archive)->basename('.tgz');
path($basename)->mkpath;
system qw(aunpack -X), $basename, $archive;
}