dsb has asked for the wisdom of the Perl Monks concerning the following question:
My question has to do with the "magically appears in the global $AUTOLOAD variable of the same package as the AUTOLOAD routine" section....if an AUTOLOAD subroutine is defined in the package or packages used to locate the original subroutine, then that AUTOLOAD subroutine is called with the arguments that would have been passed to the original subroutine. The fully qualified name of the original subroutine magically appears in the global $AUTOLOAD variable of the same package as the AUTOLOAD routine
If $AUTOLOAD is initialized by perl as a global in the package the routine is in, why must it be fully qualified or explicitly declared with our when used within that package when strict is in use.
This error:# the following code throws a compile time error package TestPackage; use strict; sub AUTOLOAD { print $AUTOLOAD, " is not available\n"; } # this code is fine package TestPackage; use strict; our $AUTOLOAD; # 'use vars qw( $AUTOLOAD )' works too sub AUTOLOAD { print $AUTOLOAD, " is not available\n"; }
I'm sure I've misinterpreted, but I just don't see where.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Fully qualifying TT$AUTOLOAD/TT
by demerphq (Chancellor) on May 02, 2002 at 15:53 UTC | |
|
(crazyinsomniac: qualify it) Re: Fully qualifying $AUTOLOAD
by crazyinsomniac (Prior) on May 03, 2002 at 07:59 UTC | |
|
Re: Fully qualifying $AUTOLOAD
by broquaint (Abbot) on May 02, 2002 at 15:58 UTC | |
|
Re: Fully qualifying $AUTOLOAD
by rinceWind (Monsignor) on May 02, 2002 at 16:04 UTC |