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>
In reply to Re: Counting lines as I write them...
by Fletch
in thread Counting lines as I write them...
by sigzero
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |