Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
- From: Geoff Cox <gcox@xxxxxxxxxx>
- Date: Tue, 19 May 2009 19:35:33 +0100
On Tue, 19 May 2009 06:58:37 -0500, Tad J McClellan
<tadmc@xxxxxxxxxxxxxx> wrote:
If you change the requirements, the code wil likely need to be changed.
( my $name = $_ ) =~ s/\.zip$/.doc/i or return;
That is vestigial.
It used to have a purpose, but now has no purpose.
If you no longer want to replace with "doc", then you need to remove
code that replaces with "doc".
Tad,
I don't understand this. The code below gives an xls extension to the
new files where the original zip file conatined an xls file, a ppt
extension to those which contained a ppt file and a doc extension to
those which contained a doc file and the same base name as the
original zip files - but! It only works if the
( my $name = $_ ) =~ s/\.zip$/.doc/i or return;
line is present. If it isn't I get
can't call method "memberNames" on an undefined value at ***
What is happening?!
Geoff
use warnings;
use strict;
use File::Find;
use Archive::Zip;
my $dir = 'c:/a-temp2/docs';
find( sub {
( my $name = $_ ) =~ s/\.zip$/.doc/i or return;
my $zip = Archive::Zip->new( $_ );
my($arch_ext) = ($zip->memberNames)[ 0 ]; ***
$arch_ext =~ s/.*\.//; # strip all but the extension
my $basename = $_;
$basename =~ s/\..*//; # strip off the extension
$zip->extractMember( ($zip->memberNames)[ 0 ],
"$basename.$arch_ext" );
unlink $_ or warn "Cannot delete $_: $!";
}, $dir );
.
- Follow-Ups:
- References:
- Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
- From: Geoff Cox
- Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
- From: Tad J McClellan
- Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
- From: Geoff Cox
- Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
- From: Tad J McClellan
- Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
- Prev by Date: Re: Generate Word and Powerpoint files
- Next by Date: Re: beginner array of array... thank you all
- Previous by thread: Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
- Next by thread: Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?
- Index(es):
Relevant Pages
|