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

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

Greetings,
 Im using Cache::Memcached in my script. The following call to stats() will throw warnings if the memcached server is not running:
use warnings; use Cache::Memcached; my $memd = new Cache::Memcached {servers => ["$host:$port"]}; my $stats = $memd->stats();
  I want to trap such warnings as errors (so I can eval/die in my code), hence I tried this in my code:
use warnings FATAL => 'all';
Since, the above pragma will not "leak across files" according to perllexwarn, Im forced to do this:
$SIG{'__WARN__'} = sub { die $_[0]};
not that anything is wrong with setting up signal handlers, I want to know if I can somehow use the warnings pragma to achieve the same. Thanks.