sub blah{print +shift;} my $word = 'BLAHBLAH'; blah( do{ (local $_= $word) =~ s/BLAH/COW/g; $_} ); # prints COWCOW print $word; # prints BLAHBLAH