Aug 11, 2006 #1 isodbaar Programmer Joined Aug 11, 2006 Messages 3 Location CA Hi guys, Im a Perl beginner.. There is a way to use a scalar as a pattern in a Regex expression? This is what I am trying to do.. $test = "m/Test/"; if ("Test" =~ $test ) { print "yep"; } Does not work!!.. Thank you in advance...
Hi guys, Im a Perl beginner.. There is a way to use a scalar as a pattern in a Regex expression? This is what I am trying to do.. $test = "m/Test/"; if ("Test" =~ $test ) { print "yep"; } Does not work!!.. Thank you in advance...
Aug 11, 2006 1 #2 KevinADC Technical User Joined Jan 21, 2005 Messages 5,070 Location US use the 'qr' (quote regexp) operator to compile and save a regexp to a variable: Code: $test = qr/Test/; if ("Test" =~ $test ) { print "yep"; } Upvote 0 Downvote
use the 'qr' (quote regexp) operator to compile and save a regexp to a variable: Code: $test = qr/Test/; if ("Test" =~ $test ) { print "yep"; }