in reply to Re^4: Precompiling substitution regex
in thread Precompiling substitution regex

Using a doubled  /e regex modifier is also possible and, IMHO, better because it is simpler. (The  /e modifier can be repeated any number of times for additional 'levels' of expression evaluation.)

c:\@Work\Perl>perl -wMstrict -le "my @SUB_REC = map [ qr{$_->[0]}, $_->[1] ], ( [ '\b(robert|bobby)\b', 'bob (not $1)' ], ) ; ;; my $yourText = 'robert dobbs and roberto jones and bobby hope'; print qq{'$yourText'}; ;; $yourText =~ s{ $_->[0] }{ qq{qq{$_->[1]}} }xmsgee for @SUB_REC; print qq{'$yourText'}; " 'robert dobbs and roberto jones and bobby hope' 'bob (not robert) dobbs and roberto jones and bob (not bobby) hope'