use warnings; use strict; use File::Find; my @warnings; { local $SIG{__WARN__} = sub {push @warnings, shift;}; find ({wanted => \&wanted}, '.'); } warn "this warning outside of File::Find, so will print normally\n"; sub wanted { # do stuff } print "caught: $_\n" for @warnings; __END__ this warning outside of File::Find, so will print normally caught: Can't cd to (./) test: Permission denied at find.pl line 10.