Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Archive::Zip Period Problem

by CodeJunkie (Monk)
on Apr 03, 2003 at 09:49 UTC ( #247717=perlquestion: print w/replies, xml ) Need Help??

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

I have a slightly silly problem with archive::zip

I want to have a program that just unzips all files in an archive to the current directory. I managed to adapt a script from the docs for this purpose, and it works, but for some reason all the extracted files have a '.' character infront of them!!!! Weird! So my files look like this:


#!c:\perl\bin\perl use strict; use CGI::Carp 'fatalsToBrowser'; use CGI qw( :standard :html3 ); use Archive::Zip; my $form=new CGI; my ($submit)=param('submit'); print "Content-type:text/html\n\n"; if ($submit) { print "Unzipping Archive...<br/>"; my $zip = Archive::Zip->new(); my $zipName = ""; my $status = $zip->read( $zipName ); die "Read of $zipName failed\n" if $status != AZ_OK; $zip->extractTree(); } else { print "<form name=\"install\" method=\"post\" action=\"install.cgi\" +> <input type=\"submit\" name=\"submit\" value=\"Install >>\"/> </form>"; }

I'm not sure why this is happening, can someone help me? I could always rename all the files after extracting, but this is not the neatest way of doing it i'm sure.


Replies are listed 'Best First'.
Re: Archive::Zip Period Problem
by Anonymous Monk on Apr 03, 2003 at 11:32 UTC
    I think extractTree() somehow gets confused with extracting to the current directory "." and forgets to append the path separator. Try:
    $zip->extractTree("", ".\\");
    worked for me.

      cheers mate, that fixed it!

      $zip->extractTree("", ".\\");

      Actually that fixed it on my windows Perl, but when I put it on a remote unix/linux machine it changed all the files to


      Which was even worse cause my ftp program couldn't see the files so I had to manually rename them using command prompt ftp... fun fun fun

        $zip->extractTree("", "./"); should work on both OSes.

        Makeshifts last the longest.

Re: Archive::Zip Period Problem
by hacker (Priest) on Apr 03, 2003 at 11:47 UTC
    What about using getcwd() and friends from Cwd?
    use strict; use Cwd; # Remember to untaint $dir my $dir = getcwd();

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://247717]
Approved by robartes
Front-paged by Courage
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2020-10-29 13:48 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (271 votes). Check out past polls.