http://qs321.pair.com?node_id=93328


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.