Hi all,
new problem encountered - I am trying to write a short
script that will search a pattern in file names that
are either within a directory or inside a zip archive
in some directory. I managed to get the results I
needed while the files were within zip archives (or
unarchived) however now I see some of the archives are
tar.gz and the code doing the trick with the zip
archives obviously are not working when applied to a
tar.gz file.
so the code below i swhat I use for zip archives:
use Archive::Zip;
use Archive::Extract;
use File::Find;
#start searching
&File::Find::find(sub{
if($_ =~/\.zip/)
{#if you find a zip file - open and read
my $zip = Archive::Zip->new();
$zip->read($_) == 0 or die "Can't read ZIP file";
foreach my $member ($zip->members)
{
my $zip_member = $member->fileName;
if($zip_member =~/$search_pattern/)
{
print "\nI FOUND 1 file!\n";
#must extract this file from the archive
$zip->extractMember($member, "C:/somepath"); }
}
}
elsif($_ =~/\.tar\.gz/)
{#if you find a tar.gz file - open and read ???
#build an Archive::Extract object
my $ae = Archive::Extract->new(archive => $_);
my @files = $ae->files;
? i don't know if I can go on here ...
else
{
if($_ =~m/$search_pattern/)
{
print "\nI FOUND 1 file!\n";
#move this file to some directory
}
}
}, $search_directory);
So, I guess I don't know what is the equivalent module
for tar.gz that would do the same thing as
Archive::Zip for zip ... (I tried Archive::Extract but
I got nowhere).
Any help would be appreciated,
Thanks,
Dan
Yahoo! Music Unlimited
Access over 1 million songs.
http://music.yahoo.com/unlimited
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs