Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Non-destructive string substitution

by fruiture (Curate)
on Apr 20, 2004 at 18:29 UTC ( #346741=note: print w/ replies, xml ) Need Help??


in reply to Non-destructive string substitution

The key is to copy the data you want to preserve. If you need this kind of behaviour very often, write a simple subroutine that does what you want.

sub cdo(&$){ local $_ = $_[1]; $_[0]->(); $_ } my $foo = 'abc'; print cdo { s/abc/def/ } $foo; print "\n$foo\n";

TI, of course, MTOWTDI.

--
http://fruiture.de


Comment on Re: Non-destructive string substitution
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2015-07-04 10:51 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 (59 votes), past polls