in reply to Re^2: To be, or not to be, an object ?
in thread To be, or not to be, an object ?
Back OT, if the conditional were to change to ... if ($@ =~ /can't call method without a package or object ref/) {..., then the problem would, methinx, be circumvented unless there was a package perverse enough to die "can't call method..." in an overloaded isa().Yes. Except that I always hated this kind of hack, because it relies on the exact phrase of the error message. Which might be subject to change, to l10n or whatever.
BTW, wouldn't your latter point put at risk all that we're told regarding the use (pun unintended this time:-) of eval to catch errors and handle them locally - the risk of DESTROY f%*&^ing things up in such circumstances must be almost omnipresent... mustn't it ??
Yes, it is indeed. There was a lengthy thread on p5p about that, and how to fix it.
Thankfully only very few modules actually use a eval inside a DESTROY block without localizing $@ first.
If you don't need a return value from the eval block, you can also do this check:
my $success = eval { # your stuff here... 1; };
and then check for the truthness of $success.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: To be, or not to be, an object ?
by Bloodnok (Vicar) on Jul 27, 2008 at 23:14 UTC |