~~David~~ has asked for the wisdom of the Perl Monks concerning the following question:

I have to extract a file from a .zip archive. There is one problem: the file can have one of two different names. Right now, I am getting around the problem by attempting to extract both of them, and one of them obviously fails and throws an error. Is there a way of fixing this problem so I don't get the error
my @zipimages; $zipimages[0] = 'Patch/Archive/picture1.tif'; $zipimages[1] = 'Patch/Archive/picture2.tif'; my $zip = Archive::Zip->new("$picturedir\\$picturefile"); foreach (@zipimages){ $tempref = $zip->extractMember( $_, picture.tif) }
The error is " error: member not found."
~~David~~

Replies are listed 'Best First'.
Re: Archive::Zip Error When Extracting Non-existent Member
by Fletch (Bishop) on Nov 28, 2007 at 21:30 UTC

    Perhaps the blindingly obvious: checking for the presence of the file in the archive first (using the memberNamed method; if it returns undef the archive doesn't contain a file by that name) . . .

Re: Archive::Zip Error When Extracting Non-existent Member
by aquarium (Curate) on Nov 28, 2007 at 22:15 UTC
    @zipimages = glob("Patch/Archive/picture[1-2].tif");
    untested
    the hardest line to type correctly is: stty erase ^H