using perl to display zip file contents

Reply

Join Date: May 2005
Posts: 45
Reputation: derekn is an unknown quantity at this point 
Solved Threads: 0
derekn derekn is offline Offline
Light Poster

using perl to display zip file contents

 
0
  #1
Jul 21st, 2009
I would like to enable users to view the contents of a zip file via CGI interface. I have tinkered around with Archive::Zip, Archive::Zip::MemberRead, and Archive::Extract, and can't seem to figure out a way to work. After perusing the net for a solution to this, it seems that perhaps the only thing that these do is to either output into another file, directory, or at best, I get a result printed out of "HASH::blah blah blah". If anyone could shed some light as to how to do this, I would sure appreciate it.

Again, to clarify, I would like to actually display the files that are contained within the respective zip file. For example, a zip has "txt1.txt, txt2.txt, txt3.txt", screen would display these filenames to user.

Derek
Last edited by derekn; Jul 21st, 2009 at 10:32 pm.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 1
Reputation: L8onw is an unknown quantity at this point 
Solved Threads: 0
L8onw L8onw is offline Offline
Newbie Poster

Re: using perl to display zip file contents

 
0
  #2
Jul 24th, 2009
I use IO::Uncompress::Unzip like so

  1. #!/usr/bin/perl -w
  2. use IO::Uncompress::Unzip qw($UnzipError);
  3.  
  4. my $zipfile = "t.zip";
  5. my $u = new IO::Uncompress::Unzip $zipfile
  6. or die "Cannot open $zipfile: $UnzipError";
  7.  
  8. my $status;
  9. for ($status = 1; ! $u->eof(); $status = $u->nextStream()) {
  10.  
  11. my $filename = $u->getHeaderInfo()->{Name};
  12. print "$filename\n" ;
  13.  
  14. }
  15.  
  16. die "Error processing $zipfile: $!\n" if $status < 0 ;

Hope this helps.
L
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC