ZZamboni has asked for the wisdom of the Perl Monks concerning the following question:
Is there a way to make Perl call a class' AUTOLOAD method before going up on @ISA? For example, in the following code:
I get the following output:package A; sub new { my $class=shift; my $self={}; bless $self, $class; return $self; } sub doit { print "doit in A\n"; } package B; @ISA=qw(A); sub AUTOLOAD { print "autoload in B, called as $AUTOLOAD\n"; } package main; $a=B->new; $a->doit;
What I would like is to have it call AUTOLOAD on B when doit is not found, before looking for it in A, so that I get:doit in A autoload in B, called as B::DESTROY
Can this be done?autoload in B, called as B::doit autoload in B, called as B::DESTROY
Thanks a lot,
--ZZamboni
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to call AUTOLOAD before @ISA?
by perlmonkey (Hermit) on May 10, 2000 at 05:18 UTC | |
by ZZamboni (Curate) on May 10, 2000 at 05:20 UTC | |
by chromatic (Archbishop) on May 10, 2000 at 18:33 UTC | |
by perlmonkey (Hermit) on May 10, 2000 at 05:45 UTC | |
|
Re: How to call AUTOLOAD before @ISA?
by btrott (Parson) on May 10, 2000 at 07:11 UTC | |
|
RE (tilly) 1: How to call AUTOLOAD before @ISA?
by tilly (Archbishop) on Sep 28, 2000 at 00:20 UTC | |
|
Re: How to call AUTOLOAD before @ISA?
by Anonymous Monk on Sep 28, 2000 at 00:01 UTC |