in reply to Re^9: Reusing a complex regexp in multiple spots, escaping the regexp
in thread Reusing a complex regexp in multiple spots, escaping the regexp
I think that's what /o was invented for
If a regexp contains something interpolated, I don't know if /o can do much for it. Consider:
my $foo = qr/foo/; while ( get_line($fh) =~ m/($foo)(bar)/ ) { ...; $foo = qr/FOO/; # $foo gets changed }
Even if $foo doesn't change, the fact that it has the potential to change makes any attempt at avoiding recompiling the larger regexp broken.
perldoc perlre does note that /o is pretty broken.
|
|---|