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

Hello Monks,

I'm having trouble geting an object I have written to do what I want with the AutoLoader module. I have created a new perl module with h2xs -X and have written a number of functions. Whenever I make && make install the module, I can use it and call my object contructor's new method via my $obj = new PackageName without any problems. However, when I modify my code so it includes the following:

use AutoLoader; ## Not importing AUTOLOAD method. sub AUTOLOAD { goto &AutoLoader::AUTOLOAD; }
The code still compiles, but I have errors when I try to call the constructor method:
Can't locate auto/.al in @INC (@INC contains:

My knowledge of how AutoLoader is pretty much limited to what I have read in the perldoc, but if I'm calling the new method, should it be looking for auto/packagname/new.al? And if not, why doesn't this fail whenever I bypass my AUTOLOAD sub and just import the AUTOLOAD method from AutoLoader?

  • Comment on AutoLoader no longer looks for .al files in the same place when I write my own AUTOLOAD
  • Download Code

Replies are listed 'Best First'.
Re: AutoLoader no longer looks for .al files in the same place when I write my own AUTOLOAD
by ehdonhon (Curate) on Nov 14, 2001 at 04:44 UTC

    DOH!

    Found the answer about 3 minutes after I posted my question. I needed to add the following to my AUTOLOAD sub:

    $AutoLoader::AUTOLOAD = $mypackage::AUTOLOAD

    Makes sense now that I think about it.