|
|
| more useful options | |
| PerlMonks |
subroutine within regex quantifier?by hagen (Friar) |
| on Dec 04, 2001 at 09:31 UTC ( #129266=perlquestion: print w/ replies, xml ) | Need Help?? |
|
hagen has asked for the
wisdom of the Perl Monks concerning the following question:
Is it possible to use a `named constant’ in a regex’s quantifiers? I want to restrict the value of `word length’ to being stored in just the one place and so, using constant.pm (as described in Perl Debugged by Peter Scott and Ed Wright) I’ve come up with the following
… which works fine, but requires the extra $Word_Length variable that, something tells me, a good Perlophone would eschew 8-) I'm aware (Perl Debugged again) that the `name constant' is constructed as a subroutine when it's defined, and returns its value when it's called. So I've tried ...{WORD_LENGTH()} based on `if it looks like a function, it is a function'. I also tried ...{&WORD_LENGTH} both with and without `()'s. Monks advice keenly sought… /hagen
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||