#!/usr/bin/perl -w use strict; use diagnostics; use warnings FATAL => 'all'; use Data::Dumper; $Data::Dumper::Useperl = 1; $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Useqq = 1; $Data::Dumper::Deparse = 1; use Params::Validate qw(:all); sub foo { validate( @_, { 'bar' => 1, # mandatory 'baz' => 0, # optional } ); print "Hello Nurse!\n"; } foo('bar' => "arg1"); sub qux { validate( @_, {} ); print "Empty Hash\n"; } qux('test'); #### $ perl crap2.pl Hello Nurse! Uncaught exception from user code: Odd number of parameters in call to main::qux when named parameters were expected at crap2.pl line 25 main::qux('test') called at crap2.pl line 31 at crap2.pl line 25 main::qux('test') called at crap2.pl line 31 #### ... eval { local $SIG{__WARN__} = sub { print STDERR "HOOKED __WARN__\n"; print STDERR Carp::longmess(); return(); }; local $SIG{__DIE__} = sub { print STDERR "HOOKED __DIE__\n"; print STDERR Carp::longmess(); exit(1); # or in your case return() }; # Examples - message not printed due to hooks. # CORE::warn("Warn Message:\n", @_, "\n"); # CORE::die("Died Message:\n", @_, "\n"); $DT = DateTime->new( year => $year, time_zone => $tz ); }; return if $@; ... #### ... eval { $tz = DateTime::TimeZone->new( name => 'Europe/London' ); $DT = DateTime->new( year => $year, time_zone => $tz ); }; return if $@; ...