Yet another *.tar.gz && *.tgz file expander. Yeah, I know this is probably an overused theme, but I needed to write one for my machines, so here is my version.
#!/usr/bin/perl -w
$|++;
use strict;
my (@list, $d, $i);
die "Need Directory Param!\n" unless $ARGV[0];
my $cmd = qq/tar -zxvf/;
opendir LOCAL,$ARGV[0];
@list = readdir LOCAL;
foreach $d (0..$#list)
{
if($list[$d] =~ /.+\.tar\.gz/)
{
qx/$cmd $list[$d]/;
$i++;
}
elsif($list[$d] =~ /.+\.tgz/)
{
qx/$cmd $list[$d]/;
$i++;
}
}
print "$i files expanded!\n";
closedir LOCAL;