Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: counter for each regex match.

by Laurent_R (Abbot)
on May 04, 2013 at 08:16 UTC ( #1032004=note: print w/replies, xml ) Need Help??


in reply to counter for each regex match.

However, I kept receiving use of uninitialized value $count error and a long string of numbers at the end as the result.

From your own description of the problem, the main point is to move the print statement outside of the while loop, so that it gets executed only once after you have finished looping on the input.

Initializing $count to 0 when you declare it is slightly less important, but it will avoid the "uninitialized value" warning in the case where nothing was matched in your while loop.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1032004]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2016-09-28 17:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (533 votes). Check out past polls.