Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: How to count substrings in an array?by mbethke (Hermit) |
on Feb 03, 2013 at 07:11 UTC ( [id://1016784]=note: print w/replies, xml ) | Need Help?? |
Edit: forum glitch? As is evident from the title this should have ended up here The "goatse operator" can make this a bit shorter and faster: $count =()= $string =~ /RE/; counts the number of matches in $string, so does what you want. It evaluates the regex in list context so it returns the list of matches and then forces it to scalar context without assigning the list anywhere.
In Section
Seekers of Perl Wisdom
|
|