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

I am using Activeperl version Perl v5.10.1 I have a zip file called c:\perl\data\my.zip containing one file called file1.txt which is an ascii file. I would like to use the Uncompress::Unzip utility or anything else to merely read file1.txt file and count the number of occurances of a string 'X.X' in it. If I were reading a simple ascii file instead of a zip file my program will look as follows.

$LOGFILE = 'c:\perl\data\file1.txt'; open(LOGFILE) or die("Could not open log file."); $mycount = 0; foreach $line (<LOGFILE>) { chomp($line); if ($line eq 'x.x'){ $mycount++; } } print "Found a total of $mycount occurances of x.x!\n"; close(LOGFILE);

Replies are listed 'Best First'.
Re: Reading zip files
by syphilis (Archbishop) on Dec 05, 2009 at 09:52 UTC
      Archive::Zip::MemberRead was perfect since I did not want to go to the trouble of manually unzipping the file. Thanks a bunch to both of you for the help. Best Rgds.
Re: Reading zip files
by Ratazong (Monsignor) on Dec 05, 2009 at 09:38 UTC
    Hi!
    When I'm confronted with .zip-files, I usually unzip the files I'm interested in to a temp-directory and then work "normally" on them...
    just an idea by Rata