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:
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Cache::Memcached and converting warnings to fatal
by mscharrer (Hermit) on Apr 21, 2008 at 19:50 UTC | |
Re: Cache::Memcached and converting warnings to fatal
by Narveson (Chaplain) on Apr 21, 2008 at 21:05 UTC | |
Re: Cache::Memcached and converting warnings to fatal
by rhesa (Vicar) on Apr 21, 2008 at 21:40 UTC |
Back to
Seekers of Perl Wisdom