Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > use File::Archive extracting zip's with '.' in front of name

Reply
Thread Tools

use File::Archive extracting zip's with '.' in front of name

 
 
david
Guest
Posts: n/a
 
      07-26-2003
I have a script to extract any ZIP files in the current directory. The
problem is when they are extracted, the program puts a . in front of
the file names.

#!/usr/bin/perl -w

use strict;
use Archive::Zip qw(:ERROR_CODES);

opendir(DIR, ".") || die "Can't open local directory : $!";
my @zips = grep { -f "./$_" } readdir (DIR);
close(DIR);
foreach my $zipfiles (@zips) {
if ($zipfiles =~ /\w+\.zip$/) {
my $zip = Archive::Zip->new();
my $zipName = "$zipfiles";
my $status = $zip->read( $zipName);
die "Read of $zipName failed\n" if $status != AZ_OK;
print "$zipfiles\n";
$zip->extractTree();
#unlink($zipfiles);
}

}

If I have a file called a.zip with a file in it called 'a', the script
will extract it as '.a'

How can I get around this?

Thanks,
 
Reply With Quote
 
 
 
 
Sisyphus
Guest
Posts: n/a
 
      07-27-2003

"david" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> I have a script to extract any ZIP files in the current directory. The
> problem is when they are extracted, the program puts a . in front of
> the file names.
>
> #!/usr/bin/perl -w
>
> use strict;
> use Archive::Zip qw(:ERROR_CODES);
>
> opendir(DIR, ".") || die "Can't open local directory : $!";
> my @zips = grep { -f "./$_" } readdir (DIR);
> close(DIR);
> foreach my $zipfiles (@zips) {
> if ($zipfiles =~ /\w+\.zip$/) {
> my $zip = Archive::Zip->new();
> my $zipName = "$zipfiles";
> my $status = $zip->read( $zipName);
> die "Read of $zipName failed\n" if $status != AZ_OK;
> print "$zipfiles\n";
> $zip->extractTree();
> #unlink($zipfiles);
> }
>
> }
>
> If I have a file called a.zip with a file in it called 'a', the script
> will extract it as '.a'
>


I don't think Archive::Zip is supposed to do this - but it does (for me on
Win2k, perl 5.6.1).

> How can I get around this?
>


I think you'll get around it with :
$zip->extractMember($member_name);

See Archive::Zip docs.

Hth,

Cheers,
Rob


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting hte font name from a TrueType font file Steve Holden Python 0 09-18-2008 04:58 PM
* in front of function name? cmk128@hotmail.com C Programming 9 03-20-2006 02:35 AM
extracting front bits from an unsigned long long? Digital Puer C Programming 36 11-13-2005 12:05 PM
Server name is being added in front of my modal dialog title on Win2003 Moshe Katz Javascript 1 05-06-2004 06:34 PM
How do I create my front page for my domain name. Rob HTML 5 12-28-2003 12:58 AM



Advertisments