D
David Wake
I want to do a case-insensitive regexp match if and only if the variable
$insensitive is set.
One way would be
if ($insensitive) {
/($pattern)/i;
}
else {
/($pattern)/;
}
Is there any way to do this with only one line of regexp searching?
I tried this:
my $searchoption = "";
$searchoption .= "i" if $insensitive;
/($pattern)/$searchoption;
but I get a syntax error.
Obviously, if we have three or four options the problem gets
exponentially bigger. For example, options for "i", "s" and "g" would
require eight possibilities. So it would be a big help if there is an
easy way to do this!
Thanks,
David
$insensitive is set.
One way would be
if ($insensitive) {
/($pattern)/i;
}
else {
/($pattern)/;
}
Is there any way to do this with only one line of regexp searching?
I tried this:
my $searchoption = "";
$searchoption .= "i" if $insensitive;
/($pattern)/$searchoption;
but I get a syntax error.
Obviously, if we have three or four options the problem gets
exponentially bigger. For example, options for "i", "s" and "g" would
require eight possibilities. So it would be a big help if there is an
easy way to do this!
Thanks,
David