in reply to To be, or not to be, an object ?
Update: Your suggested solution has a (nearly obvious) pitfall:
sub Foo::isa { die "bla" }; my $ref = bless {}, 'Foo'; eval { $ref->isa() }; if ($@) { print "Not an object\n"; } else { print "An object\n"; }
Also in general this construct:
eval { ... } if ($@) { ... }
Isn't all that reliable because a DESTROY sub might clear $@ accidentally. Rather use
if (eval {...; 1}){ ... }
Instead (Ok, this is nit-picking, but you asked for reliability...).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: To be, or not to be, an object ?
by Bloodnok (Vicar) on Jul 25, 2008 at 13:32 UTC | |
by moritz (Cardinal) on Jul 27, 2008 at 20:18 UTC | |
by Bloodnok (Vicar) on Jul 27, 2008 at 23:14 UTC |