in reply to Regular expression modifiers in a scalar

You want modifiers inside the regex:

my $modifiers = 'i'; my $text = 'abc'; my $pattern = 'BC'; if ( $text =~ m/(?$modifiers:$pattern)/) { print "it matches\n"; }

Only good for turning on (or off) options imsx. See perlre.

print "Just another Perl ${\(trickster and hacker)},"
The Sidhekin proves Sidhe did it!

Replies are listed 'Best First'.
Re^2: Regular expression modifiers in a scalar
by wintermte (Initiate) on Jul 24, 2006 at 03:31 UTC
    Excellent. That is exactly what I was looking for! Thanks for the quick reply.