Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://93328]
help
Chatterbox?
[marto]: it's a shame Solaris is such a PITA to build on :)
LanX great movie!

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2017-07-28 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (426 votes). Check out past polls.