in reply to find a string a certain number of times
basic perl stuff ... no need to get crazy ... yes , you do not need the array, if you are only counting. Your regular exp may need some fussing, but that's the fun. Cheersuse strict; my $count; my @array; open FILE, "filename"; while (<FILE>){ push @array, $_; } foreach $a(@array){ if ($a =~ m/whatever/ ) { $count ++; } } print $count,"\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: find a string a certain number of times
by Roy Johnson (Monsignor) on Jan 30, 2005 at 12:55 UTC |