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;
with
my $foo = $bar;
$foo =~ s/this/that/;
Is there a better solution?
require v5.14;
in your header…) – Saulsuse v5.13.2
is the minimum level fors///r
. – Sauls