in reply to counter for each regex match.
$count's initial state is "undef", or undefined. It doesn't get incremented until the first time that "mailto:" shows up in your input file. Yet you print its value on each iteration.
So imagine the first line of your file is, "More pizza please!". The regex obviously won't match, and so $count won't be incremented. So when you print $count's value, it is still 'undef'.
Either initialize it with a value right where you're declaring $count, or move it outside of the foreach loop, or put an "if defined $count" suffix at the end of your print statement.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: counter for each regex match.
by tty1x (Novice) on May 04, 2013 at 12:51 UTC |