in reply to Why doesn't' eval{} trap die() when using File::Find?
use File::Find; my @dirlist = ('.', '.', 'nonexistant'); foreach my $dir (@dirlist){ eval { find( \&wanted, $dir ) }; # Does NOT work when passing +a reference to foo to the find module # eval { bar() }; # DOES work when just calling a subroutine dir +ectly if( $@ ){ print "$dir had error: ".$@; } else { print "processed $dir\n"; } } sub wanted{ die "haha!"; } sub bar{ die "haha!"; }
. had error: haha! at a.pl line 18. . had error: haha! at a.pl line 18. processed nonexistant
In what way does it not work for you? Could it be that your version of F::F actually catches the exceptions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why doesn't' eval{} trap die() when using File::Find?
by Sukotto (Novice) on Aug 04, 2010 at 17:52 UTC |