Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Non-destructive substitution?

by epoptai (Curate)
on Jul 03, 2001 at 01:17 UTC ( #93328=note: print w/ replies, xml ) Need Help??

in reply to Non-destructive substitution?

There is a cleaner way, but you still need the temporary variable to preserve $string. I assume you need $string later which is the only reason you'd need a non-destructive substitution. You can declare and substitute in one step:

(my$tmp = $string) =~ s/foo/blah/;

Check out my Perlmonks Related Scripts like framechat, reputer, and xNN.

Comment on Re: Non-destructive substitution?
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2015-11-25 21:13 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (691 votes), past polls