Think about Loose Coupling | |
PerlMonks |
Re^3: How to Remove Commas ?by tobyink (Canon) |
on Mar 27, 2012 at 14:06 UTC ( [id://961936]=note: print w/replies, xml ) | Need Help?? |
The s/// operator by default removes only the first match. So:
There are various flags you can include to alter its default behaviour though. One of the most useful is the "g" (global) flag...
Note that the slashes may be replaced with other characters, so you could equally write:
Or even:
... which some people might find more readable. Though note that there are a handful of characters (hash, question mark and single quote spring to mind) that trigger special behaviours here (perlop has more details).
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In Section
Seekers of Perl Wisdom
|
|