... Even though it looks like a regular function call, it isn't: you can't take a reference to it, such as the incorrect "\&CORE::open" might appear to produce. ...
To get around this you could use an anonymous subroutine as the value to $DEFAULT_HANDLER.
our $DEFAULT_HANDLER = sub { die @_ };
Making this change seems to work.
bruce:1:~/tmp $ cat p.pl #!/usr/bin/perl # vim: sw=4 use strict; use warnings; package fred; our $DEFAULT_HANDLER = sub { die @_ }; our $AUTOLOAD; sub AUTOLOAD { print STDERR "AUTOLOAD(@_) - $AUTOLOAD\n"; my $self = shift; $DEFAULT_HANDLER->('died via indirection'); } package main; my $fred = fred->raise_exception("some test"); bruce:1:~/tmp $ ./p.pl AUTOLOAD(fred some test) - fred::raise_exception died via indirection at ./p.pl line 9. bruce:1:~/tmp $
In reply to Re: Problem using code ref's in AUTOLOAD
by bruceb3
in thread Problem using code ref's in AUTOLOAD
by Bloodnok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |