in reply to Counting lines as I write them...
So count them as you print them.
my %count; ## ... if( "!!!" eq substr $line => 0, 3 ) { $count{ "!!!" }++; print OUTFILE $line; } ## ... print "Total errors for $_: $count{ $_ }\n" for qw( @@@ *** !!! );
Update: And no one else has mentioned it, but you might want while( defined( $line = <INFILE> ) ) { ... } if 0\n might occur in your input.</pedant>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Counting lines as I write them...
by Tanktalus (Canon) on Apr 11, 2005 at 15:16 UTC | |
by Fletch (Bishop) on Apr 11, 2005 at 15:43 UTC |