in reply to Non-destructive string substitution
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.
|
|---|