D
David Liang
Sorry for the newcomer question; I couldn't find anything related.
What I'd like to do is compile and check if a regular expression is
proper:
$re = '[bad';
eval { $foo = qr/$re/; };
if ($@) {
# ...
}
I was thinking the eval would catch normally fatal errors, but it
doesn't catch the regex error. The program crashes with:
Unmatched [ in regex; marked by <-- HERE in m/[ <-- HERE bad/
at ...
Am I doing anything wrong? Is there a better way to do this?
Thanks.
What I'd like to do is compile and check if a regular expression is
proper:
$re = '[bad';
eval { $foo = qr/$re/; };
if ($@) {
# ...
}
I was thinking the eval would catch normally fatal errors, but it
doesn't catch the regex error. The program crashes with:
Unmatched [ in regex; marked by <-- HERE in m/[ <-- HERE bad/
at ...
Am I doing anything wrong? Is there a better way to do this?
Thanks.