in reply to Using constants in regexes?
Use the (?{ CODE }) experimental feature at your own risk:
use constant TEST => 'def'; my $string = 'abcdefg'; if ($string =~ /(?{TEST})/) { print "The string contains the constant.\n"; }else{ print "The string doesn't contain the constant.\n"; }
Aziz,,,
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Answer: Using CODEconstant/CODEs in regexes?
by japhy (Canon) on Aug 11, 2001 at 03:11 UTC | |
by abstracts (Hermit) on Aug 11, 2001 at 03:20 UTC |
In Section
Seekers of Perl Wisdom