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"?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Count replaces in search and replace
by kennethk (Abbot) on Mar 11, 2009 at 17:07 UTC | |
|
Re: Count replaces in search and replace
by ikegami (Patriarch) on Mar 11, 2009 at 17:56 UTC | |
|
Re: Count replaces in search and replace
by VinsWorldcom (Prior) on Mar 12, 2009 at 14:30 UTC | |
by kennethk (Abbot) on Mar 12, 2009 at 15:42 UTC | |
by VinsWorldcom (Prior) on Mar 13, 2009 at 01:32 UTC |