print do { (my $t = $_ ) =~ s/foo/bar/g };
Update: Ah, missed the without temp variables qualifier. You could use the similar do { local($_)=$_; s/foo/bar/g }, which uses the block's stack rather than an explicit temporary.
In reply to Re: Non-destructive string substitution
by Fletch
in thread Non-destructive string substitution
by Sprad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |