in reply to constants within regular expression?
This is documented in the POD for the 'constant' pragma:
Constants defined using this module cannot be interpolated into strings like variables.
You can work around that behavior like this:
use constant MYTEST => '.txt'; my $expression = quotemeta( MYTEST ); my $string = "test.txt"; if ( $string =~ /$expression/ ) { print "Match\n"; }
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: constants within regular expression?
by Zed_Lopez (Chaplain) on Nov 26, 2003 at 06:34 UTC | |
by davido (Cardinal) on Nov 26, 2003 at 06:37 UTC | |
by Coruscate (Sexton) on Nov 26, 2003 at 06:43 UTC | |
by sauoq (Abbot) on Nov 26, 2003 at 07:02 UTC | |
by Anonymous Monk on Nov 26, 2003 at 07:18 UTC |