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 applies to the modifier r , without which the code works. However, I do not want to change $bar . I can of course replace
my $foo = $bar =~ s/this/that/r;
from
my $foo = $bar; $foo =~ s/this/that/;
Is there a better solution?
source share