in reply to Idiom for a regex translation

If you find it ugly, hide it in a subroutine.

In this case, do something like

sub replace (&$) { local $_ = $_[1]; &{$_[0]}(); $_; }
which you can later use as
$newstr = replace { s/k/w/ } $oldstr;
which does not change $oldstr.

Also, you can find similar functionality in the Sed cpan module.