in reply to Overloading ref() just like ->isa and ->can?

Actually, the best practices recommendation should be:
eval { local $SIG{__DIE__}; $obj->isa( ... ); }
Otherwise, you will trigger all SIGDIE handlers and, not surprisingly, Test::More has one.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

Replies are listed 'Best First'.
Re^2: Overloading ref() just like ->isa and ->can?
by ysth (Canon) on Aug 23, 2006 at 01:19 UTC
    Otherwise, you will trigger all SIGDIE handlers and, not surprisingly, Test::More has one.
    Test::Builder, actually. To whit:
    $SIG{__DIE__} = sub { # We don't want to muck with death in an eval, but $^S isn't # totally reliable. 5.005_03 and 5.6.1 both do the wrong thing # with it. Instead, we use caller. This also means it runs under # 5.004! my $in_eval = 0; for( my $stack = 1; my $sub = (CORE::caller($stack))[3]; $stack+ ++ ) { $in_eval = 1 if $sub =~ /^\(eval\)/; } $Test_Died = 1 unless $in_eval; };
    I'm afraid that eval{} users have to be allowed the ease-of-coding advantage over die-handlers. The whole purpose of eval is to catch an exception; you shouldn't have to go through additional hoops to protect against an exception. Yes, there's a perl design botch, but eval{} shouldn't have to suffer for it. (As far as I know, $^S is working in newer perls, which should make things a little easier.)