Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Search and replace problem

by atcroft (Monsignor)
on Jan 10, 2012 at 05:22 UTC ( #947105=note: print w/ replies, xml ) Need Help??


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.


Comment on Re: Search and replace problem
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://947105]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2015-07-03 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls