in reply to Regular Expression problem with $variable =~ m/C++/
my $re = quotemeta($VarString); next unless $Array[$Counter] =~ m/$re/;
Another trick is to use \Q...\E.
next unless $Array[$Counter] =~ m/\Q$VarString\E/;
By the way, do realize that if $VarString = 'C';, (poorly named) $Array[0] would match because there's a C in VISUAL BASIC? You also have problems with $VarString = 'VB'; (doesn't exist) and $VarString = 'Perl'; (case issue)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Regular Expression problem with $variable =~ m/C++/
by mtar (Novice) on Jun 12, 2007 at 12:37 UTC | |
by ikegami (Patriarch) on Jun 12, 2007 at 16:35 UTC |