in reply to Re^2: calling subroutines within a regular expression?
in thread calling subroutines within a regular expression?

This doesn't seem to work:
>perl -wMstrict -le "use constant RX => qr{ [atc]{3} }xms; my $s = 'the cat in the hat'; print 'found' if $s =~ /${+RX}/; print qq{found a $1} if $s =~ /(${+RX})/; " Use of uninitialized value in regexp compilation ... found Use of uninitialized value in concatenation (.) or string ... found a

Replies are listed 'Best First'.
Re^4: calling subroutines within a regular expression?
by Your Mother (Archbishop) on Apr 05, 2009 at 05:30 UTC

    You're right. It looked like it worked on the original to me because it matched "cat" against "" which "found" it. The + is a way to force constants to evaluate, also works, in some contexts, with spelling it out as the sub it is, RX(). Doesn't work here though. :(