use warnings; my @x = qw(a b c); $SIG{__WARN__} = sub { print "got a warning: $_[0]\n"; CORE::dump; }; for (0..3) { print "$x[$_]\n"; }