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

I've got a set of modules and scripts that I've just written and I'm trying to figure out why they can't find each other. First off, the errors:

Can't locate package Apps::WWW::Base for @Apps::WWW::Configurators::IS +A at index.cgi line 21. Can't locate package CGI::Application::MixIn::Upload for @Apps::WWW::C +onfigurators::ISA at index.cgi line 21. Can't locate package CGI::Application::MixIn::Auth for @Apps::WWW::Con +figurators::ISA at index.cgi line 21.

The script that uses the modules couldn't be any more straightforward, with all the local directories needed through use lib:

use lib ('/big/dom/xclickautomation/Projects/Admin_Site/lib', # Home o +f Apps::WWW::Configurators and Apps::WWW::Base '/big/dom/xclickautomation/lib/', # home of CGI::Application: +:MixIn modules, used in Apps::WWW::Configurators '/big/dom/xclickautomation/lib/CPAN/lib/perl5/site_perl/5.005 +/' #my local CPAN installs ); use strict; #------------------------------------- # IN HOUSE MODULES use Apps::WWW::Configurators; #===================================================================== +===================================== # MAIN ( Apps::WWW::Configurators->new() )->run(); exit(0);

And the @ISA array at the top of Apps::WWW::Configurators:

package Apps::WWW::Configurators; @ISA = qw(Apps::WWW::Base CGI::Application::MixIn::Upload CGI::Applic +ation::MixIn::Auth);

Now, the odd thing is that the script could find Apps::WWW::Configurators, but it couldn't find Apps::WWW::Base which sits in the same exact directory. And none of this gives me much insight on why it can't find all the CGI::Application::MixIn modules. Any idea what I'm overlooking?

Edit title by tye

Replies are listed 'Best First'.
Re: wrestling with codeuse lib/code and code@ISA/code
by perrin (Chancellor) on Aug 24, 2001 at 03:50 UTC
    You forgot to use Apps::WWW::Base. You need to do that somewhere before you call methods in any class that inherits from it. You might want to use the base pragma, which protects you from this mistake. You can perldoc base for the details.
      Thanks. I had been using use base in previous programming tasks and had gotten used to not having to use inherited modules. Alas this recent work is running on a box that only has perl 5.005. The fix worked though.
Re: wrestling with codeuse lib/code and code@ISA/code
by kjherron (Pilgrim) on Aug 24, 2001 at 03:56 UTC
    Perhaps I'm jumping to conclusions, but you seem to be assuming that perl will go load the modules by itself because you assigned their package names to @ISA. This doesn't happen; each of the modules has to be loaded via "use" or "require" first. The error message is saying the relevant packages were never defined, not that perl tried and failed to find the associated files.

    Basically, The Apps::WWW::Configurators should "use" Apps::WWW::Base and the others, or "use" a module that "uses" them, or something along those lines.

Re: wrestling with codeuse lib/code and code@ISA/code
by Rudif (Hermit) on Aug 24, 2001 at 03:15 UTC
    AidanLee wrote

    >> I'm trying to figure out why they can't find each other...

    use lib ('/big/dom/xclickautomation/Projects/Admin_Site/lib', # Home o +f Apps::WWW::Configurators and Apps::WWW::Base

    Perl is looking for files

    /big/dom/xclickautomation/Projects/Admin_Site/lib/Apps/WWW/Configurato +rs.pm /big/dom/xclickautomation/Projects/Admin_Site/lib/Apps/WWW/Base.pm
    Is that exactly where the files are? And no spelling mistakes?

    HTH
    Rudif

      No spelling mistakes. As I said, it's finding Configurators.pm just fine, but not Base.pm