in reply to Counting lines as I write them...

Update: syntax errors - '$' missing
open( INFILE, "<$filename" ) || die "$!\n"; open( OUTFILE, ">>dataload.errs" ) || die "$!\n"; my %total; while ( $line = <INFILE> ) { if ( "***M" eq substr $line => 0, 4 ) { print OUTFILE $line; $total{'***'}++ } if ( "!!!" eq substr $line => 0, 3 ) { print OUTFILE $line; $total{'!!!'}++ } if ( "@@@" eq substr $line => 0, 3 ) { print OUTFILE $line; $total{'@@@'}++ } } close( INFILE ); close( OUTFILE ); print "$_ $total{$_}\n" for keys %total
Update:
print "Total errors for $_: $total{$_} \n" for keys %total


Replies are listed 'Best First'.
Re^2: Counting lines as I write them...
by Fletch (Bishop) on Apr 11, 2005 at 14:33 UTC

    total{'***'}++ et al will work much better (and in fact will actually compile) with the correct leading sigil ($) . . .