Consider:
#!/usr/bin/perl -w
use strict;
my $match= "hi";
my $re= qr/($match)/;
print "\$match is $match\n";
print "'chimp' matches (", 'chimp' =~ $re, ")\n";
$match= "lo";
print "\$match is $match\n";
print "'slow' matches (", 'slow' =~ $re, ")\n";
print "'chimp' matches (", 'chimp' =~ $re, ")\n";
produces
$match is hi
'chimp' matches (hi)
$match is lo
'slow' matches ()
'chimp' matches (hi)
So why does the
qr// operator support the /o option? It already appears to only compile the regex once even without /o.
-
tye
(but my friends call me "Tye")