in reply to perl calls die() as a method
Deparse is often wrong in corner-cases, including this one:
My perl's deparse does better (v5.8.6) (updated to reflect code below):
BEGIN { $^W = 1; } use AA::BB; use strict 'refs'; print "Caught exception $@" unless eval { do { &CORE::GLOBAL::die('AA::BB'->new) } }; test.pl syntax OK
You're better off trying to run the code in any case: yours doesn't work because there is no AA::BB::new method.
update:
#! /usr/bin/perl -w use strict; use AA::BB; eval { die AA::BB->new; } or print "Caught exception $@";
Output:package AA::BB; sub die(@) { print "die called with args '@_'" }; sub import { *CORE::GLOBAL::die = \¨ } sub new { return bless {},shift; } 1;
update2 in other words, your code is allright except for the missing new() method, and deparse is wrong. You should do more checking in your code and try not to depend Deparse.die called with args 'AA::BB=HASH(0x81761c8)'
Also, overriding CORE::GLOBAL::die is completely evil: it can easily break exceptions (as my modified code shows).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl calls die() as a method
by chibiryuu (Beadle) on Aug 18, 2005 at 14:57 UTC | |
by Joost (Canon) on Aug 18, 2005 at 16:02 UTC | |
|
Re^2: perl calls die() as a method
by kappa (Chaplain) on Aug 18, 2005 at 15:11 UTC |