Scarborough has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

I have looked at AUTOLOAD on the perldocs and found this

If an AUTOLOAD is found, this method is called on behalf of the missing method, setting the package global $AUTOLOAD to be the fully qualified name of the method that was intended to be called.

I've tried this

package mypackage; use strict; missingsub('a','b'); sub AUTOLOAD{ my $args = @_; #I'm getting these args. print $AUTOLOAD; #but this gives me a syntex error #Global symbol $AUTOLOAD requires explicit pac +kage name at.. }

Where am I going wrong.

UPDATE$AUTOLOAD is there I can see it in debug but I can only use it with strict off it seems

20040910 Edit by broquaint: Changed title from 'AUTOLOAD not doing what I expected'

Replies are listed 'Best First'.
Re: Global symbol $AUTOLOAD requires explicit package name at
by gellyfish (Monsignor) on Sep 09, 2004 at 14:07 UTC

    Yep you need to:

    use vars qw($AUTOLOAD); or our $AUTOLOAD;
    In the appropriate package.

    /J\

Re: Global symbol $AUTOLOAD requires explicit package name at
by trammell (Priest) on Sep 09, 2004 at 14:18 UTC
    $AUTOLOAD is a package global, so you can make the error go away by referring to it as e.g. $mypackage::AUTOLOAD.
Re: Global symbol $AUTOLOAD requires explicit package name at
by Prior Nacre V (Hermit) on Sep 09, 2004 at 14:35 UTC

    There's further information on this in pertoot.

    It's also recommended that you trap DESTROY() methods: this might be applicable to your application; it's generally a good defensive programming manoeuvre.

    Regards,

    PN5

Re: Global symbol $AUTOLOAD requires explicit package name at
by Scarborough (Hermit) on Sep 09, 2004 at 16:14 UTC
    Thanks for your help on this one. With the other answer I got today to another question, I have had my most productive day this year.