my %count; @count(qw/@@@ *** !!!/) = (0) x 3; #### if ( "!!!" eq substr $line => 0, 3 ) { $count{'!!!'}++; print OUTFILE $line; } #### printf "Total errors for %s: %d\n", $_, $count{$_} for keys %count;