Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

PERL5LIB-How does it work

by Anonymous Monk
on Sep 18, 2007 at 06:38 UTC ( [id://639559]=perlquestion: print w/replies, xml ) Need Help??

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

Hello,
This is a question for my edification. I had thought that if one puts a directory in PERL5LIB, perl would search that director and all subdirectories for modules. I had in my .profile
PERL5LIB=\
/hdb10/Perl/PerlLibs/lib/perl5/5.8.8/:\
/hdb10/Perl/PerlLibs/lib/perl5/site_perl/5.8.8/:
Perl couldn't find Tagset.pm. I used find and found it was dir under the HTML directory, and so I added a third line
PERL5LIB=\
/hdb10/Perl/PerlLibs/lib/perl5/5.8.8/:\
/hdb10/Perl/PerlLibs/lib/perl5/site_perl/5.8.8/:\
/hdb10/Perl/PerlLibs/lib/perl5/site_perl/5.8.8/HTML
and it worked. Would someone be so kind as explain the rules for seaching for modules.
Thanks in advance for any help
klee12

Replies are listed 'Best First'.
Re: PERL5LIB-How does it work
by Corion (Patriarch) on Sep 18, 2007 at 06:57 UTC

    Your error is that, in your program, you have the line:

    use TagSet;

    where you should have the line

    use HTML::TagSet;

    Then, the original setting of PERL5LIB would work as advertised. The package is named HTML::TagSet, so Perl goes looking for a file HTML/TagSet.pm below each entry in PERL5LIB (or rather, @INC, which gets amended by PERL5LIB.

      Thanks Corion.
      Actually I wasn't using the Tagset.pm. I encountered it while installing libwww-perl-5.808.tar.gz and it complained it couldn't find Tagset. I used find . -name "Tagset*" and got
      ./lib/perl5/site_perl/5.8.8/i486-linux-thread-multi/auto/HTML/Tagset
      ./lib/perl5/site_perl/5.8.8/HTML/Tagset.pm
      
      The first line referred to an empty directory. I'm not sure if this is a bug. If someone thinks it is a bug, perhaps they could report it.
      Thanks again.
      klee12
Re: PERL5LIB-How does it work
by bruceb3 (Pilgrim) on Sep 18, 2007 at 06:50 UTC
    I am the human manual.
    $ perldoc -t perlrun | less +/PERL5LIB

    PERL5LIB
    A list of directories in which to look for Perl library files before looking in the standard library and the cur- rent directory. Any architecture-specific directories under the specified locations are automatically included if they exist. If PERL5LIB is not defined, PERLLIB is used. Directories are separated (like in PATH) by a colon on unixish platforms and by a semicolon on Windows (the proper path separator being given by the command "perl -V:path_sep"). When running taint checks (either because the program was running setuid or setgid, or the -T switch was used), nei- ther variable is used. The program should instead say: use lib "/my/directory";

      Thanks,bruceb3. I found that but didn't read it carefully. That seems to say that it looks only at the files in the directory unless there is are "architecture-specific directories". Since they descended into "archtecure-specific directories" I had assumed they descended into all directories.
      klee12
Re: PERL5LIB-How does it work
by ikegami (Patriarch) on Sep 18, 2007 at 18:14 UTC

    The module should be located at .../site_perl/5.8.8/HTML/Tagset.pm.
    The module should be loaded using use HTML::Tagset;.

    Sounds like
    the module is incorrectly located at .../site_perl/5.8.8/HTML/HTML/Tagset.pm, or
    the module is incorrectly loaded using use Tagset;.

    Adding .../site_perl/5.8.8/HTML to @INC in order to omit HTML:: from the use directive is bound to lead to problems.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://639559]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 23:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found