Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

unexpected use lib behavior

by davidj (Priest)
on Oct 23, 2006 at 09:38 UTC ( #579968=perlquestion: print w/replies, xml ) Need Help??
davidj has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,
I'm getting unexpected behavior using  use lib; It seems that the only directory my module can be found in is a subdirectory of the directory out of which the pages are being served. Also, when I don't  use lib; and put the module in my PERL5LIB directory, Perl complains that it cannot be found. I have verified that all is setup correctly. Here is what I have: (in the script)
use lib "/home/davidj/perl/lib/survey";
directory listing:
andromeda:davidj lib > pwd /home/davidj/perl/lib/survey andromeda:davidj survey > ls -l total 4 -rw-r--r-- 1 davidj users 1444 Oct 23 03:09
http error output:
[Mon Oct 23 03:23:49 2006] [error] [client] Can't locate sur in @INC (@INC contains: /home/davidj/perl/lib/survey /usr/lib/ +perl5/site_perl/5.8.8/i386-linux-thread-multi .....
I have tested other directories and nothing seems to work. However, if I do this:
use lib "/var/www/cgi-bin/survey/lib/";
and put the module file in that directory, with the pages being served out of /var/www/cgi-bin/survey, it all works fine.

It is fine for me to store modules in the application subdirectories. I'm just wondering why Perl cannot find them anywhere else, including my exported PERL5LIB directory.


Replies are listed 'Best First'.
Re: unexpected use lib behavior
by Tomte (Priest) on Oct 23, 2006 at 09:49 UTC

    While the file is readable by everyone (rw-r--r--), is the directory /home/davidj/perl/lib/survey accessible by the user the www-server runs as (r-x for others the whole way down)?


    An intellectual is someone whose mind watches itself.
    -- Albert Camus

      Well, dang it. I thought I had resolved the directory permissions, but I didn't.

      Thanks all,
Re: unexpected use lib behavior
by gellyfish (Monsignor) on Oct 23, 2006 at 09:50 UTC

    I think you'll find it is to do with the permissions on the directories.


Re: unexpected use lib behavior
by tinita (Parson) on Oct 23, 2006 at 09:47 UTC
    well, you don't show your code where you use survey;. are you doing this before the use lib line maybe?
Re: unexpected use lib behavior
by andyford (Curate) on Oct 23, 2006 at 09:44 UTC
      I am not forgetting. The problem happens only when I take the module out of an app subdirectory and change the corresponding use lib; directory.
      #!/usr/bin/perl -T use strict; use warnings; #use lib "/var/www/cgi-bin/survey/lib"; use lib "/home/davidj/perl/lib/survey"; use CGI qw/standard/; use survey;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://579968]
Approved by tinita
[Discipulus]: there is also find2perl with your perl installation
[Discipulus]: and in the wanted sub you just calculate the duretion and add it the total, stop
[shmem]: sub wanted { push @files, $File::Find::name if $File::Find::name =~/\.mp3$/ }
[Lady_Aleena]: shmem, that is understandable! The two examples in File::Find don't make sense to me on a quick glance.
[marioroy]: LA if the find worked from Unix command line, or does it not. Likely a quoting issue inside Perl qx.
[Lady_Aleena]: marioroy, the find worked fine at the command line.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (12)
As of 2017-04-23 20:52 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (432 votes). Check out past polls.