my $regex = param('foo'); $regex = eval { qr/$regex/ }; if ($@) { "it was bad... handle it" }