http://qs321.pair.com?node_id=310154

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear perl monks: The following code (or something like it) will check the RE in $re for proper syntax. However, -w finds other useful trouble conditions, which it reports to STDERR. I would like to detect these warnings and act on them, and not display them. Can this be done?
#!/usr/bin/perl -w $re = '[\w-]'; eval {'' =~ /$re/ } if($@) {print "error: $@\n"}