sub x { my ($x) = @_; # $x is an array ref to a DB record local $SIG{__WARN__} = sub { my $msg = shift; print STDERR "*******\n"; print STDERR $msg; print STDERR "current DB record: id=", $x->[ID]; }; # some stuff that might cause a Warning.... # some operations on the record pointed to by $x # maybe "abc123" is not numeric, etc. return $result; }