wintermte has asked for the wisdom of the Perl Monks concerning the following question:
The perl interpreter obviously doesn't like this because it is expecting an operator instead of the scalar $modifiers. Is there a way to do this other than a big if elsif statement that covers all of the various operators that may be in $modifiers? Using qr doesn't work any better to build the expression. Thanks in advance.my $modifiers = 'i'; my $text = 'abc'; if ( $text =~ m/$pattern/$modifiers) { print "it matches\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular expression modifiers in a scalar
by Sidhekin (Priest) on Jul 24, 2006 at 03:20 UTC | |
by wintermte (Initiate) on Jul 24, 2006 at 03:31 UTC | |
|
Re: Regular expression modifiers in a scalar
by Zaxo (Archbishop) on Jul 24, 2006 at 03:31 UTC | |
by wintermte (Initiate) on Jul 24, 2006 at 12:21 UTC |