Perl When is using AUTOLOAD OK?

Posted by Robert S. Barnes on Stack Overflow See other posts from Stack Overflow or by Robert S. Barnes
Published on 2010-03-17T08:43:25Z Indexed on 2010/03/17 8:51 UTC
Read the original article Hit count: 412

Filed under:
|
|

In "Perl Best Practices" the very first line in the section on AUTOLOAD is:

Don't use AUTOLOAD

However all the cases he describes are dealing with OO or Modules.

I have a stand alone script in which some command line switches control which versions of particular functions get defined. Now I know I could just take the conditionals and the evals and stick them naked at the top of my file before everything else, but I find it convenient and cleaner to put them in AUTOLOAD at the end of the file.

Is this bad practice / style? If you think so why, and is there a another way to do it?

© Stack Overflow or respective owner

Related posts about perl

Related posts about best-practices