in reply to Counting occurances of a pattern in a file

When you use while (<INPUT>), doesn't each line get put in $_ ? Try replacing if (<INPUT> =~ /regexp/ ) with if (/regexp/). If that doesn't work for some reason, here's a cheesier workaround that I think will work. @array = <INPUT> foreach $line (@array) { if ( $line =~ /regexp/ ) { do stuff } elsif ( $line =~ /other regexp/ ) { do other stuff } } As a totally unrelated side note, I believe your "next" commands and your final "else" are totally unnecessary. Hope this helps.
  • Comment on RE: Counting occurances of a pattern in a file