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

What is Autoloading and what does it do?

Replies are listed 'Best First'.
Re: What is autoloading?
by chromatic (Archbishop) on Nov 25, 2007 at 05:04 UTC

    When Perl dispatches a method call, it may not find an appropriate method to invoke. In that case, it will dispatch to a special method called AUTOLOAD as a last resort. This allows you to do whatever's appropriate for your class in the case of a missing method.

    You can catch errors in this fashion or write really simple proxy or delegation systems. Some code uses this to compile code as necessary, but that's not really as useful in my opinion.

      Some code uses this to compile code as necessary, but that's not really as useful in my opinion.

      It is useful if you have a module with lots of functions, of which you will need only some, e.g. POSIX.

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: What is autoloading?
by TOD (Friar) on Nov 25, 2007 at 04:27 UTC
    perldoc perltoot
    --------------------------------
    masses are the opiate for religion.