http://www.perlmonks.org?node_id=995330


in reply to capture errors from eval

I'd do it like this:
my $re = eval { qr/$x/ }; if ($@) { ... } else { $string =~ $re }