Perl docs recommend this:
$foo = $bar =~ s/this/that/r;
However, I get this error:
Bareword found where operator expected near "s/this/that/r" (#1)
This is specific to the "r" modifier, without it the code works. However I do not want to modify $bar. I can, of course, replace
my $foo = $bar =~ s/this/that/r;
my $foo = $bar; $foo =~ s/this/that/;
Is there a better solution?