The problem is that m// binds by default to $_ in the absence of an explicit binding, e.g., $s =~ m{pattern}; A poor, naked qr// doesn't know what to bind to and must always be bound explicitly as BrowserUk has done.
In general, the interpolation of a constant into a regex is messy:
use constant FOO => qr{ foo }xms;
print 'got foo' if 'foo' =~ m{ @{[ FOO ]} }xms;
The use of a Readonly constant makes things neater:
use Readonly;
Readonly my $FOO => qr{ foo }xms;
print 'got foo' if 'foo' =~ m{ $FOO }xms;
but BrowserUk will tell you that the Readonly module has some dirty little secrets of its own. YMMV.
In reply to Re: calling regular expressions returned by functions?
by AnomalousMonk
in thread calling regular expressions returned by functions?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |