Well, lots of languages use Perl compatible regexps now, even MariaDB uses PCRE nowadays.
my $a = 'Perl';
my $b = $a;
$b =~ s/pe/ea/i;
Why not do something to $a and obtain $b, just like js does with Array.map. Why the need to copy $a into to $b and then replace? Much more ellegant in Ruby: a = 'Ruby'
b = a.gsub(/ru/i, 'mo') my $a = 'Perl';
my $b =~ s/pe/ea/ir; % perl -MData::Dumper=Dumper -e 'my $a = 'Perl'; my $b =~ s/pe/ea/ir; print Dumper $b;'
$VAR1 = undef;
You probably mean: my $a = 'Perl';
my $b = $a =~ s/pe/ea/ir;
Anyway, thank you for the /r modifier, it didn't know what it did, since there's no example in perlre(1).I'm surprised there's no example in perlre(1); perhaps I can get that corrected.