<?xml version="1.0" encoding="windows-1252"?>
<node id="305975" title="Re: Why does this work? AUTOLOAD sans sub declaration" created="2003-11-10 16:06:40" updated="2005-06-15 07:49:37">
<type id="11">
note</type>
<author id="17361">
converter</author>
<data>
<field name="doctext">
&lt;p&gt;
Since the perlsub POD mentions the AUTOLOAD subroutine in the same sentence as "BEGIN", "CHECK", "INIT", "END", "CLONE" and "DESTROY", I assume it shares some of the same characteristics as the others, the important one in this case being that the &lt;code&gt;sub&lt;/code&gt; keyword is implied.
When fed your code, [cpan://B::Deparse] prints the following. Notice how the &lt;code&gt;sub&lt;/code&gt; keyword is inserted for the BEGIN subs, as well as the AUTOLOAD sub:
&lt;/p&gt;
&lt;code&gt;
package Foo;
use warnings;
use strict 'refs';
our $AUTOLOAD;
sub main::BEGIN {
    package main;
    no strict 'refs';
    require strict;
    do {
        'strict'-&gt;import
    };
}
sub main::BEGIN {
    package main;
    require warnings;
    do {
        'warnings'-&gt;import
    };
}
sub new {
    return bless({}, shift @_);
}
sub do_something {
    print 'did something';
}
sub AUTOLOAD {
    print "message from Foo: undefined method ($AUTOLOAD) called";
}
package main;
my $instance = 'Foo'-&gt;new;
$instance-&gt;do_something;
$instance-&gt;do_notimplemented;
&lt;/code&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-17361"&gt;
&lt;p&gt;
[converter]
&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
305965</field>
<field name="parent_node">
305965</field>
</data>
</node>
