braswell has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; package Foo; our $AUTOLOAD; sub new { return bless {}, shift } sub do_something { print "did something" } AUTOLOAD { # note it's missing the 'sub' declaration print "message from Foo: undefined method ($AUTOLOAD) called"; } package main; my $instance = Foo->new; $instance->do_something; # prints "did something" $instance->do_notimplemented; # prints "message from Foo: undefinded m +ethod (Foo::do_notimplemented) called
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why does this work? AUTOLOAD sans sub declaration
by converter (Priest) on Nov 10, 2003 at 21:06 UTC | |
|
Re: Why does this work? AUTOLOAD sans sub declaration
by hardburn (Abbot) on Nov 10, 2003 at 21:12 UTC | |
|
Re: Why does this work? AUTOLOAD sans sub declaration
by duff (Parson) on Nov 10, 2003 at 21:44 UTC | |
by Aristotle (Chancellor) on Nov 11, 2003 at 01:48 UTC | |
|
Re: Why does this work? AUTOLOAD sans sub declaration
by batkins (Chaplain) on Nov 10, 2003 at 20:50 UTC | |
by chromatic (Archbishop) on Nov 10, 2003 at 22:44 UTC | |
by batkins (Chaplain) on Nov 10, 2003 at 23:40 UTC |