in reply to Re: Substituting without modifying
in thread Substituting without modifying
Running under ActiveState 5.6.1 and Windows ME, the above code first returns the temporary value of "changed it" and then the original value of "bar baz".use strict; my $foo = "bar baz"; { (my $foo = $foo) =~ s/bar/quux/; # do something with the modified $foo $foo = "changed it"; print "The temporary value of foo is $foo.\n"; } # now the original $foo is back again print "The original value of foo is $foo.\n";
|
|---|