in reply to How many ways are there to use AUTOLOAD?

Personally, I use AUTOLOAD for two things.

Firstly, in Class::Autouse, to enable run-time class loading, normally on a per module basis, but with a fast-and-loose option of hooking it into UNIVERSAL::AUTOUSE and handling any random call

Secondly, I also use it in some Template Toolkit stuff to catch calls, and then find the property within the context of the call. Basically making TT do what you'd expect it to.

I'm not sure I understand why you are doing this though? Doesn't perl general errors anyway when you call a method that doesn't exist? Wouldn't just catching and logging the $@ in an eval be exactly what you wanted anyway?
  • Comment on Re: How many ways are there to use AUTOLOAD?

Replies are listed 'Best First'.
Re^2: How many ways are there to use AUTOLOAD?
by skx (Parson) on Jul 21, 2004 at 13:14 UTC

    I use AUTOLOAD when templating too.

    I find that when building an application with CGI::Application, CGI::Session, and HTML::Template I have two types of subroutines:

    • Those that exist to do something, view or update a database.
    • Those that just exist to populate a couple of pieces of information on a static page, like a FAQ.

    The second set of subroutines I handle by having an AUTOLOAD test to see if the application was called with a run mode for which there exists a template. If so it just populates it with "standard" things and returns it.

    Steve
    ---
    steve.org.uk