in reply to Re^3: calling subroutines within a regular expression?
in thread calling subroutines within a regular expression?
I can't test this right now, but I think the following works and also gives you a more elegant regex interpolation:
Should print:use warnings; use strict; use Readonly; Readonly my $BAR => qr{ bar }xms; my $string = q{fie foo bar baz barf}; print qq{found $1} if $string =~ m{ foo \s* ($BAR) \s* baz }xms;
found bar
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: calling subroutines within a regular expression?
by Bloodnok (Vicar) on Apr 05, 2009 at 10:31 UTC |