Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex from variable 1

Status
Not open for further replies.

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...


 
use the 'qr' (quote regexp) operator to compile and save a regexp to a variable:

Code:
$test = qr/Test/;
if ("Test" =~ $test ) {
   print "yep";
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top