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 reply to Re: Search and replace problem
by atcroft
in thread Search and replace problem
by Thakur
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |