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 | |
by Dell (Initiate) on Dec 06, 2009 at 06:01 UTC | |
|
Re: Reading zip files
by Ratazong (Monsignor) on Dec 05, 2009 at 09:38 UTC |