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
In reply to Why does this work? AUTOLOAD sans sub declaration by braswell
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |