in reply to can't find my module?

Also, don't use the names of existing core modules for your modules. "base" is a core module that helps with object inheiritance. Lowercase names are reserved for prgma modules. Other modules usually begin with capital letter and are mixed case.

Replies are listed 'Best First'.
Re: Re: can't find my module?
by arootbeer (Novice) on Nov 20, 2003 at 03:59 UTC

    I read through all of perlmod, and am familiar with the conventions. However, since this is a completely private module, I wanted to be able to use existing values to access the modules directly (although I've since implemented a hash using the values).

    I stated before, that I've tried several different names for each of several .pm files (base was probably a bad example :) Because I'm using the hash, I can really name them anything I want to now. However, this opens up a new question:

    Shouldn't my program have been able to

    require base
    if base is a preexisting module? (My feeling is that, because it's a core module, it can't be directly used or required.)

    45 minutes later:I was able to find a different module (haven't played with the "base" one again), but I had to name it something different than what I had intended. (I had intended Nfs.pm, but that was never found, so I used "Nfs_module.pm", and it found that just fine). So I guess my question now becomes, why can't I use an arbitrary name for a perl module?

      Yes, you should be able to use:
      require base;
      But that's not what the original code does. It does the equivalent of:
      require "base";
      which is different. The former goes out looking for a file called 'base.pm', while the latter goes out looking for a file called 'base'.
      $ perl -wle 'require "base"' Can't locate base in @INC (@INC contains: /home/abigail/Perl /opt/ +perl/lib/5.8.2/i686-linux-64int-ld /opt/perl/lib/5.8.2 /opt/perl/lib/ +site_perl/5.8.2/i686-linux-64int-ld /opt/perl/lib/site_perl/5.8.2 /op +t/perl/lib/site_perl/5.8.1/i686-linux-64int-ld /opt/perl/lib/site_per +l/5.8.1 /opt/perl/lib/site_perl/5.8.0 /opt/perl/lib/site_perl .) at - +e line 1. $ perl -wle 'require "base.pm"' $

      This is documented in perldoc -f require.

      Abigail

      Shouldn't my program have been able to require base if base is a preexisting module?

      Yes it should. If doing require base gets you an error there is something wrong with your Perl installation since it has been core since Perl v5.005. What error did you get?

      was able to find a different module (haven't played with the "base" one again), but I had to name it something different than what I had intended. (I had intended Nfs.pm, but that was never found, so I used "Nfs_module.pm", and it found that just fine). So I guess my question now becomes, why can't I use an arbitrary name for a perl module?

      Nfs.pm is a valid module name and should work perfectly - what error did you get?

        Well, I've de-modularized my code for the momen, but I was able to recreate the problem by adding require "base"; back at the top.

        The error message is as follows:

        Can't locate base in @INC (@INC contains: ./focus /usr/opt/perl5/lib/5.8.0/aix-t
        hread-multi /usr/opt/perl5/lib/5.8.0 /usr/opt/perl5/lib/site_perl/5.8.0/aix-thre
        ad-multi /usr/opt/perl5/lib/site_perl/5.8.0 /usr/opt/perl5/lib/site_perl .) at s
        l_observe.pl line 8.

        (Although, as per the second comment, using require base works just fine.) The error message was the same for Nfs.pm; however, Nfs_module.pm was found. I was having more problems (specifically getting the variables I'm using exported correctly) so, for the sake of getting the code to production level, it's currently de-modularized.