[sf-perl] SanFrancisco-pm Digest, Vol 52, Issue 13
Lane Davis
pm at upt.org
Tue May 26 12:30:18 PDT 2009
Quoting sanfrancisco-pm-request at pm.org:
> i'm trying to interpolate a value in a compiled regex. it's
> interpolating the first time, but not the second. that is:
>
> [some snippage...]
>
> Readonly my $FOO => 'foo';
> Readonly my $FOO_REGEX => qr{ $FOO [^#]+ -D $FOO }xms;
>
The use of the /x modifier causes the '#' character to be seen as introducing a
comment, even if it's all neatly contained in one qr() entry. Normally we're
used to a character class auto-quoting stuff for us, but when combined with /x
you'll have to manually quote it:
Readonly my $FOO => 'foo';
Readonly my $FOO_REGEX => qr{ $FOO [^\#]+ -D $FOO }xms;
Cheers,
-L
--
http://upt.org/lane
-------------------------------------------------
FastQ Communications
Providing Innovative Internet Solutions Since 1993
More information about the SanFrancisco-pm
mailing list