in reply to Why doesn't' eval{} trap die() when using File::Find?

First, there are some typos in your code. Specifically, on line 6 you've swapped a } for a ) and you have an extra } on your commented line 8. It is generally considered good form to test code before you post (How do I post a question effectively?).

Fixing those, I do not have any trouble trapping the die when I modify your directory list to correspond to an actual directory in my tree. If the directory does not exist, your wanted sub never executes. Are you sure that perl is executing at the path you think it is? Also note that if you have warnings enabled, your eval will not catch File::Find's emitted warnings.

use File::Find; my @dirlist = qw(.); foreach my $dir (@dirlist){ eval { find( \&wanted, $dir ); }; # Does NOT work when passing a r +eference to foo to the find module # eval { bar() ; }; # DOES work when just calling a subroutine dire +ctly if( $@ ){ print "$dir had error: ".$@; } else { print "processed $dir\n"; } } sub wanted{ die "haha!"; } sub bar{ die "haha!"; }