Dear monks,
am writing an simple program, its throwing error
#!/usr/local/bin/perl
$regex = '\d+';
$mod = 'i'
$string = 'my age is 30';
#if($string =~ m/$regex/i) # -- works
if($string =~ m/$regex/$mod) # this line gives error
{
print "Matched";
}
else
{
print "not matched";
}
when i run it
BL05ACLS: ~ 51 > regex.cgi
Scalar found where operator expected at ./regex.cgi line 8, near "m/$regex/$mod"
syntax error at ./regex.cgi line 8, near "m/$regex/$mod"
Execution of ./regex.cgi aborted due to compilation errors.
In reply to configurable regex match by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |