f



Can't locate module despite 'use lib'

As an experiment in module creation I have the following script, 'ex.pl':

#!/usr/bin/perl -wT

use strict;
use lib qw(/home/zarg/pl);
use Ex;

begin_now();

---------------------
Ex.pm is located in /home/zarg/pl with mode 644:

package Ex;

use Exporter;
@ISA = ("Exporter");
@EXPORT = qw(&begin_now);

use strict;
use CGI qw(:cgi);

sub begin_now {
  print header, '<h1>Here goes</h1>';
}
1;

-------------------------
When accessing ex.pl via the browser I get the error:

"Can't locate Ex.pm in @INC (@INC contains: /home/zarg/pl ....
BEGIN failed

Why can't the script see my module when it has found the directory it lives in?

gunzip
0
gunzip
9/25/2004 10:47:55 PM
comp.lang.perl.misc 33233 articles. 1 followers. brian (1246) is leader. Post Follow

3 Replies
649 Views

Similar Articles

[PageSpeed] 43

>>>>> "g" == gunzip  <none@none.com> writes:


  g> begin_now();

  g> Ex.pm is located in /home/zarg/pl with mode 644:

  g> use strict;
  g> use lib qw(/home/zarg/pl);
  g> use Ex;

  g> "Can't locate Ex.pm in @INC (@INC contains: /home/zarg/pl ....
  g> BEGIN failed

  g> Why can't the script see my module when it has found the directory
  g> it lives in?

it didn't find the directory, it just listed it. that means use lib
worked. there are other permission problems such as 644 on /pl. web
servers commonly run as nobody so it can't scan the directory for
entries as it need x perms for that. try 666 permission and also check
the perm on your home dir which needs to be x (searchable) by others as
well.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
0
Uri
9/25/2004 10:54:59 PM
On Sat, 25 Sep 2004 22:54:59 GMT, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "g" == gunzip  <none@none.com> writes:
> 
> 
>  g> begin_now();
> 
>  g> Ex.pm is located in /home/zarg/pl with mode 644:
> 
>  g> use strict;
>  g> use lib qw(/home/zarg/pl);
>  g> use Ex;
> 
>  g> "Can't locate Ex.pm in @INC (@INC contains: /home/zarg/pl ....
>  g> BEGIN failed
> 
>  g> Why can't the script see my module when it has found the directory
>  g> it lives in?
> 
> it didn't find the directory, it just listed it. that means use lib
> worked. there are other permission problems such as 644 on /pl. web
> servers commonly run as nobody so it can't scan the directory for
> entries as it need x perms for that. try 666 permission and also check
> the perm on your home dir which needs to be x (searchable) by others as
> well.

644 should be fine for the module itself.  But if running from a web 
server, all directories in the path to the module need at least 701 
permission (the x bit is needed on a dir to access it).  666 permission 
would be incorrect for a directory and not advisable for a file (anybody 
could modify it).
0
efflandt
9/27/2004 4:37:37 AM
>>>>> "DE" == David Efflandt <efflandt@xnet.com> writes:

  DE> On Sat, 25 Sep 2004 22:54:59 GMT, Uri Guttman <uri@stemsystems.com> wrote:
  >> it didn't find the directory, it just listed it. that means use lib
  >> worked. there are other permission problems such as 644 on /pl. web
  >> servers commonly run as nobody so it can't scan the directory for
  >> entries as it need x perms for that. try 666 permission and also check
  >> the perm on your home dir which needs to be x (searchable) by others as
  >> well.

  DE> 644 should be fine for the module itself.  But if running from a web 
  DE> server, all directories in the path to the module need at least 701 
  DE> permission (the x bit is needed on a dir to access it).  666 permission 
  DE> would be incorrect for a directory and not advisable for a file (anybody 
  DE> could modify it).

d'oh! i knew that!

this is why i use symbolic options in chmod :)

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
0
Uri
9/27/2004 4:43:11 AM
Reply: