|
|
| There's more than one way to do things | |
| PerlMonks |
Re: Search and replace problemby atcroft (Monsignor) |
| on Jan 10, 2012 at 05:22 UTC ( #947105=note: print w/ replies, xml ) | Need Help?? |
|
The problem you are having is that you have this: $string = s/Apple/Mango/g; where you actually want this: $string =~ s/Apple/Mango/g; The '=~' applies the substitution to $string, whereas the '=' tries to assign the result of the attempted substitution on $_. (May not be exactly what occurs, but pretty close.) Hope that helps.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||