|
|
| "be consistent" | |
| PerlMonks |
Count replaces in search and replaceby VinsWorldcom (Priest) |
| on Mar 11, 2009 at 17:02 UTC ( #749952=perlquestion: print w/ replies, xml ) | Need Help?? |
|
VinsWorldcom has asked for the
wisdom of the Perl Monks concerning the following question:
Using the line: $_ =~ s/$replace/$map{$replace}/gi to find $replace and replace it with the hash value of $map{$replace} case insensitive and all occurances on the given line works a treat. However, I'd like to know 'how many' replacements were done on each line. Is there an easy way to get this value that I can increment in a counter to spit out at the end of the program that would say something like "Found and replaced X items"?
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||