There's more than one way to do things | |
PerlMonks |
Re: how to count matchesby ferreira (Chaplain) |
on May 04, 2007 at 14:47 UTC ( [id://613583]=note: print w/replies, xml ) | Need Help?? |
When you did the global match (triggered by /g) was done at scalar context. In this case it finds a single match or fails. So $d will return 1 or 0. To do what you want, you need to set a list context and then count the matches. will output "matches 5".
In Section
Seekers of Perl Wisdom
|
|