Hi. I am fairly new to perl and its fair to say I am not a developer by profession. I am having an issue and can not fanthom how to resolve or workaround...

on my Linux box I have zip files and want to find out the contents. for example;

[myuser@dev2 ~]# file /tmp/test.zip /tmp/test.zip: Zip archive data, at least v2.0 to extract [myuser@dev2 ~]# unzip -l /tmp/test.zip Archive: /tmp/test.zip Length Date Time Name -------- ---- ---- ---- 19855954 08-24-10 17:06 RGB_DSC08815.jpg 11230988 08-24-10 17:05 RGB_fly43337.jpg 13285985 08-24-10 17:04 RGB_fly48151.jpg 10024136 08-24-10 17:04 RGB_fly48168.jpg 9236336 08-24-10 17:04 RGB_fly54598.jpg 7750448 08-24-10 17:03 RGB_fly57173.jpg 8870833 08-24-10 17:03 RGB_MHowell142.jpg 10178959 08-24-10 17:06 RGB_MHowell181.jpg 1151658 08-24-10 17:16 RGB_Ducky_HARD.eps 14741504 09-07-10 17:08 RGB_TEST.indd -------- ------- 106326801 10 files

but when I use the perl code below I get the error.

[myuser@dev2 ~]# ./showZipContents.pl RGB_DSC08815.jpg RGB_fly43337.jpg Error processing /tmp/test.zip:

Here i my code so far.

#!/usr/bin/perl -w use strict; use warnings; use IO::Uncompress::Unzip qw(unzip $UnzipError); my $zipfile = "/tmp/test.zip"; my $u = new IO::Uncompress::Unzip $zipfile or die "Cannot open $zipfile: $UnzipError"; my $status; for ($status = 1; ! $u->eof(); $status = $u->nextStream()) { my $filename = $u->getHeaderInfo()->{Name}; print "$filename\n" ; } die "Error processing $zipfile: $!\n" if $status < 0 ;

In reply to problems using IO::Uncompress::Unzip to get name of zip contents. by andr3w77

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.