Sukotto has asked for the wisdom of the Perl Monks concerning the following question:
Why doesn't eval{} trap the call to die() in the first case? Is that what theuse File::Find; my @dirlist = ('dir1', 'dir2', 'dir3'); 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 dir +ectly if( $@ ){ print "$dir had error: ".$@; } else { print "processed $dir\n"; } } sub wanted{ die "haha!"; } sub bar{ die "haha!"; }
$SIG{'__DIE__'} stuff is in the eval docs?
If so, would someone please explain to me what I have to do to trap the die() call in wanted()?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why doesn't' eval{} trap die() when using File::Find?
by ikegami (Patriarch) on Aug 03, 2010 at 19:55 UTC | |
by Sukotto (Novice) on Aug 04, 2010 at 17:52 UTC | |
|
Re: Why doesn't' eval{} trap die() when using File::Find?
by kennethk (Abbot) on Aug 03, 2010 at 20:02 UTC | |
|
Re: Why doesn't' eval{} trap die() when using File::Find?
by Anonymous Monk on Aug 03, 2010 at 19:59 UTC |