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).
In reply to Re: perl calls die() as a method
by Joost
in thread perl calls die() as a method
by kappa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |