Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Using the result of s///

by elusion (Curate)
on Apr 30, 2003 at 20:15 UTC ( #254449=note: print w/ replies, xml ) Need Help??


in reply to Using the result of s///

The first example you give prints the result of the substitution (the result of $string =~ s/_/ /g). If you look at the documentation for s///, you will see that it returns the number of substitutions made. It's easier to see in code.

$string = 'This_has_underscores'; $result = $string =~ s/_/ /g; print $result;
That's what the first result is equal to. The second example prints the new $string, which is what you want in this case.

elusion : http://matt.diephouse.com


Comment on Re: Using the result of s///
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2015-07-29 04:13 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 (260 votes), past polls