http://www.perlmonks.org?node_id=947105


in reply to Search and replace problem

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.