For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > February 2007 > Help with @INC









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Help with @INC
Carl Sajjan

2007-02-24, 6:58 pm



Dear List,





I am chaged with setting up LDAP monitoring using some
tool. I came across this Look.pl utility. But when I try to run this
file I got the error... I am a newbie to PERL.



perl look.pl

/usr/perl5/5.6.1/lib//sun4-solaris-64int/usr/perl5/5.6.1/lib//usr/iplane
t/perl5/lib/site/Mozilla/LDAP//usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozil
la/LDAP//usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP//usr/perl5/5.6
..1/lib/sun4-solaris-64int/usr/perl5/5.6.1/lib/usr/perl5/site_perl/5.6.1/
sun4-solaris-64int/usr/perl5/site_perl/5.6.1/usr/perl5/site_perl/usr/per
l5/vendor_perl/5.6.1/sun4-solaris-64int/usr/perl5/vendor_perl/5.6.1/usr/
perl5/vendor_perl.



Can't locate object method "new" via package "Mozilla::LDAP::Conn"
(perhaps you forgot to load "Mozilla::LDAP::Conn"?) at look.pl line 767.





Thing is I have this Conn.pm in these many locations.



/usr/perl5/5.6.1/lib/Conn.pm

/usr/iplanet/perl5/lib/site/Mozilla/LDAP/Conn.pm

/usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/Conn.pm

/usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP/Conn.pm





Where am I going wrong I tried adding the path in Use lib ...





Please help me out.





TIA



Carl

.........................................................................
..............................



The wise want love; and those who love want wisdom.

--Percy Bysshe Shelley




Paul Lalli

2007-02-24, 6:58 pm

On Feb 24, 10:25 am, Carl.Saj...@Cybertech.com (Carl Sajjan) wrote:
> I am chaged with setting up LDAP monitoring using some
> tool. I came across this Look.pl utility.


If it's malfunctioning, why aren't you complaining to the person who
wrote it from whereever you "came across" it?

> But when I try to run this
> file I got the error... I am a newbie to PERL.


Perl is the language, perl is the program. There is no PERL.

>
> perl look.pl
>
> Can't locate object method "new" via package "Mozilla::LDAP::Conn"
> (perhaps you forgot to load "Mozilla::LDAP::Conn"?) at look.pl line 767.
>
> Thing is I have this Conn.pm in these many locations.


Irrelevant. The error message is telling you that you tried to run a
method of the class, but you never *used* the class. That is, your
look.pl script does not contain the line:

use Mozilla::LDAP::Conn;

Paul Lalli

John

2007-02-24, 6:58 pm

Hi

How come your Comm.pm is in several locations?
Anyway, use "lib" to ensure opath is on the path.
I normally do the following:

#!/usr/bin/perl
use lib "../"; # parent directory
use strict;
use warnings;
use Library; my $library=new Library;
my $headtag=$library->headtag;
my $bodytag=$library->bodytag;
etc etc

Regards
John



--------------------------------------------------------------------------------
I am using the free version of SPAMfighter for private users.
It has removed 73160 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter for free now!


Ken Foskey

2007-02-24, 6:58 pm

On Sat, 2007-02-24 at 20:55 +0530, Carl Sajjan wrote:

> Can't locate object method "new" via package "Mozilla::LDAP::Conn"
> (perhaps you forgot to load "Mozilla::LDAP::Conn"?) at look.pl line 767.


do you have this near the top of your script?

use Mozilla::LDAP::Conn;


--
Ken Foskey
FOSS developer

Rob Dixon

2007-02-24, 6:58 pm

Carl Sajjan wrote:
>
> I am chaged with setting up LDAP monitoring using some tool. I came across
> this Look.pl utility. But when I try to run this file I got the error...
> I am a newbie to PERL.
>
> perl look.pl
>
> /usr/perl5/5.6.1/lib//sun4-solaris-64int
> /usr/perl5/5.6.1/lib/
> /usr/iplanet/perl5/lib/site/Mozilla/LDAP/
> /usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/
> /usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP/
> /usr/perl5/5.6.1/lib/sun4-solaris-64int
> /usr/perl5/5.6.1/lib
> /usr/perl5/site_perl/5.6.1/sun4-solaris-64int
> /usr/perl5/site_perl/5.6.1
> /usr/perl5/site_perl
> /usr/perl5/vendor_perl/5.6.1/sun4-solaris-64int
> /usr/perl5/vendor_perl/5.6.1
> /usr/perl5/vendor_perl.
>
> Can't locate object method "new" via package "Mozilla::LDAP::Conn"
> (perhaps you forgot to load "Mozilla::LDAP::Conn"?) at look.pl line 767.
>
>
> Thing is I have this Conn.pm in these many locations.
>
> /usr/perl5/5.6.1/lib/Conn.pm
>
> /usr/iplanet/perl5/lib/site/Mozilla/LDAP/Conn.pm
>
> /usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/Conn.pm
>
> /usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP/Conn.pm
>
>
> Where am I going wrong I tried adding the path in Use lib ...


If you have the line

use Mozilla::LDAP::Conn;

in your program, Perl will look in all the paths in @INC for a file with the
relative path

Mozilla/LDAP/Conn.pm

so the first of these is no use at all as it doesn't have directories Mozilla
and LDAP in the path. The rest are fine, except that none of the locations are
in @INC. If you add any of

/usr/iplanet/perl5/lib/site
/usr/ds/v5.2/nsPerl5.005_03/lib/site
/usr/ds/v5.2/nsPerl5.006_01/lib/site

to @INC then Perl will find the module correctly. Which is the best place to
use depends on the way your system is set up and where other modules are kept.

HTH,

Rob



Carl Sajjan

2007-02-24, 6:58 pm


Rob,

Thanks a lot for your reply.=20

I modified my perl file as follows , but still I get the same error.

use lib qw(/usr/perl5/5.6.1/lib/
130 /usr/iplanet/perl5/lib/site/Mozilla/LDAP/
131 /usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/
132 /usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP/
133 /usr/ds/v5.2/nsPerl5.005_03/lib/site
134 );
135
136 #use Mozilla::LDAP::Conn;
137 print (@INC, "\n\n");
138


Output:

(carl)(113): perl look.pl
/usr/perl5/5.6.1/lib//sun4-solaris-64int/usr/perl5/5.6.1/lib//usr/iplane
t/perl5/lib/site/Mozilla/LDAP//usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozil
la/LDAP//usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP//usr/ds/v5.2/n
sPerl5.005_03/lib/site/usr/perl5/5.6.1/lib/sun4-solaris-64int/usr/perl5/
5.6.1/lib/usr/perl5/site_perl/5.6.1/sun4-solaris-64int/usr/perl5/site_pe
rl/5.6.1/usr/perl5/site_perl/usr/perl5/vendor_perl/5.6.1/sun4-solaris-64
int/usr/perl5/vendor_perl/5.6.1/usr/perl5/vendor_perl.

Can't locate object method "new" via package "Mozilla::LDAP::Conn"
(perhaps you forgot to load "Mozilla::LDAP::Conn"?) at look.pl line 768.


Line 768 reads as follows

else
767 {
768 $ldap_conn =3D new
Mozilla::LDAP::Conn("$parm{'ldaphost'}", "$parm{'ldapport'}");
769 }



Thanks
Carl


















-----Original Message-----
From: Rob Dixon [mailto:rob.dixon@350.com]=20
Sent: Saturday, February 24, 2007 11:41 PM
To: Perl Beginners
Cc: Carl Sajjan
Subject: Re: Help with @INC

Carl Sajjan wrote:
>
> I am chaged with setting up LDAP monitoring using some tool. I came

across
> this Look.pl utility. But when I try to run this file I got the

error...
> I am a newbie to PERL.
>
> perl look.pl
>
> /usr/perl5/5.6.1/lib//sun4-solaris-64int
> /usr/perl5/5.6.1/lib/
> /usr/iplanet/perl5/lib/site/Mozilla/LDAP/
> /usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/
> /usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP/
> /usr/perl5/5.6.1/lib/sun4-solaris-64int
> /usr/perl5/5.6.1/lib
> /usr/perl5/site_perl/5.6.1/sun4-solaris-64int
> /usr/perl5/site_perl/5.6.1
> /usr/perl5/site_perl
> /usr/perl5/vendor_perl/5.6.1/sun4-solaris-64int
> /usr/perl5/vendor_perl/5.6.1
> /usr/perl5/vendor_perl.
>
> Can't locate object method "new" via package "Mozilla::LDAP::Conn"
> (perhaps you forgot to load "Mozilla::LDAP::Conn"?) at look.pl line

767.
>
>
> Thing is I have this Conn.pm in these many locations.
>
> /usr/perl5/5.6.1/lib/Conn.pm
>
> /usr/iplanet/perl5/lib/site/Mozilla/LDAP/Conn.pm
>
> /usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/Conn.pm
>
> /usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP/Conn.pm
>
>
> Where am I going wrong I tried adding the path in Use lib ...


If you have the line

use Mozilla::LDAP::Conn;

in your program, Perl will look in all the paths in @INC for a file with
the
relative path

Mozilla/LDAP/Conn.pm

so the first of these is no use at all as it doesn't have directories
Mozilla
and LDAP in the path. The rest are fine, except that none of the
locations are
in @INC. If you add any of

/usr/iplanet/perl5/lib/site
/usr/ds/v5.2/nsPerl5.005_03/lib/site
/usr/ds/v5.2/nsPerl5.006_01/lib/site

to @INC then Perl will find the module correctly. Which is the best
place to
use depends on the way your system is set up and where other modules are
kept.

HTH,

Rob



Carl Sajjan

2007-02-24, 6:58 pm


I tried making a few changes now and it didn't show the perl module
error... it shows a different type of error.

I gave the absolute path in the location as shown in the line below.


Illegal division by zero at Look.pl line 763.

Line 763 is $ldap_conn =3D new
/usr/iplanet/perl5/lib/site/Mozilla/LDAP/Conn("$parm{'ldaphost'}", "
$parm{'ldapport'}");


I gave the correct IP for ldaphost and 389 as port.

Has anyone used this utility?


Thanks in advance


Carl

-----Original Message-----
From: Carl Sajjan [mailto:Carl.Sajjan@Cybertech.com]=20
Sent: Sunday, February 25, 2007 12:50 AM
To: Rob Dixon
Cc: Perl Beginners
Subject: RE: Help with @INC


Rob,

Thanks a lot for your reply.=20

I modified my perl file as follows , but still I get the same error.

use lib qw(/usr/perl5/5.6.1/lib/
130 /usr/iplanet/perl5/lib/site/Mozilla/LDAP/
131 /usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/
132 /usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP/
133 /usr/ds/v5.2/nsPerl5.005_03/lib/site
134 );
135
136 #use Mozilla::LDAP::Conn;
137 print (@INC, "\n\n");
138


Output:

(carl)(113): perl look.pl
/usr/perl5/5.6.1/lib//sun4-solaris-64int/usr/perl5/5.6.1/lib//usr/iplane
t/perl5/lib/site/Mozilla/LDAP//usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozil
la/LDAP//usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP//usr/ds/v5.2/n
sPerl5.005_03/lib/site/usr/perl5/5.6.1/lib/sun4-solaris-64int/usr/perl5/
5.6.1/lib/usr/perl5/site_perl/5.6.1/sun4-solaris-64int/usr/perl5/site_pe
rl/5.6.1/usr/perl5/site_perl/usr/perl5/vendor_perl/5.6.1/sun4-solaris-64
int/usr/perl5/vendor_perl/5.6.1/usr/perl5/vendor_perl.

Can't locate object method "new" via package "Mozilla::LDAP::Conn"
(perhaps you forgot to load "Mozilla::LDAP::Conn"?) at look.pl line 768.


Line 768 reads as follows

else
767 {
768 $ldap_conn =3D new
Mozilla::LDAP::Conn("$parm{'ldaphost'}", "$parm{'ldapport'}");
769 }



Thanks
Carl


















-----Original Message-----
From: Rob Dixon [mailto:rob.dixon@350.com]=20
Sent: Saturday, February 24, 2007 11:41 PM
To: Perl Beginners
Cc: Carl Sajjan
Subject: Re: Help with @INC

Carl Sajjan wrote:
>
> I am chaged with setting up LDAP monitoring using some tool. I came

across
> this Look.pl utility. But when I try to run this file I got the

error...
> I am a newbie to PERL.
>
> perl look.pl
>
> /usr/perl5/5.6.1/lib//sun4-solaris-64int
> /usr/perl5/5.6.1/lib/
> /usr/iplanet/perl5/lib/site/Mozilla/LDAP/
> /usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/
> /usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP/
> /usr/perl5/5.6.1/lib/sun4-solaris-64int
> /usr/perl5/5.6.1/lib
> /usr/perl5/site_perl/5.6.1/sun4-solaris-64int
> /usr/perl5/site_perl/5.6.1
> /usr/perl5/site_perl
> /usr/perl5/vendor_perl/5.6.1/sun4-solaris-64int
> /usr/perl5/vendor_perl/5.6.1
> /usr/perl5/vendor_perl.
>
> Can't locate object method "new" via package "Mozilla::LDAP::Conn"
> (perhaps you forgot to load "Mozilla::LDAP::Conn"?) at look.pl line

767.
>
>
> Thing is I have this Conn.pm in these many locations.
>
> /usr/perl5/5.6.1/lib/Conn.pm
>
> /usr/iplanet/perl5/lib/site/Mozilla/LDAP/Conn.pm
>
> /usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/Conn.pm
>
> /usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP/Conn.pm
>
>
> Where am I going wrong I tried adding the path in Use lib ...


If you have the line

use Mozilla::LDAP::Conn;

in your program, Perl will look in all the paths in @INC for a file with
the
relative path

Mozilla/LDAP/Conn.pm

so the first of these is no use at all as it doesn't have directories
Mozilla
and LDAP in the path. The rest are fine, except that none of the
locations are
in @INC. If you add any of

/usr/iplanet/perl5/lib/site
/usr/ds/v5.2/nsPerl5.005_03/lib/site
/usr/ds/v5.2/nsPerl5.006_01/lib/site

to @INC then Perl will find the module correctly. Which is the best
place to
use depends on the way your system is set up and where other modules are
kept.

HTH,

Rob




--=20
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/


Rob Dixon

2007-02-25, 6:59 pm

>Carl Sajjan wrote:
>
> From: Rob Dixon
>
> Thanks a lot for your reply.
>
> I modified my perl file as follows , but still I get the same error.
>
> use lib qw(/usr/perl5/5.6.1/lib/
> 130 /usr/iplanet/perl5/lib/site/Mozilla/LDAP/
> 131 /usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/
> 132 /usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP/
> 133 /usr/ds/v5.2/nsPerl5.005_03/lib/site
> 134 );
> 135
> 136 #use Mozilla::LDAP::Conn;
> 137 print (@INC, "\n\n");
> 138
>
>
> Output:
>
> (carl)(113): perl look.pl
> /usr/perl5/5.6.1/lib//sun4-solaris-64int/usr/perl5/5.6.1/lib//usr/iplane
> t/perl5/lib/site/Mozilla/LDAP//usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozil
> la/LDAP//usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP//usr/ds/v5.2/n
> sPerl5.005_03/lib/site/usr/perl5/5.6.1/lib/sun4-solaris-64int/usr/perl5/
> 5.6.1/lib/usr/perl5/site_perl/5.6.1/sun4-solaris-64int/usr/perl5/site_pe
> rl/5.6.1/usr/perl5/site_perl/usr/perl5/vendor_perl/5.6.1/sun4-solaris-64
> int/usr/perl5/vendor_perl/5.6.1/usr/perl5/vendor_perl.
>
> Can't locate object method "new" via package "Mozilla::LDAP::Conn"
> (perhaps you forgot to load "Mozilla::LDAP::Conn"?) at look.pl line 768.
>
>
> Line 768 reads as follows
>
> else
> 767 {
> 768 $ldap_conn = new Mozilla::LDAP::Conn("$parm{'ldaphost'}", "$parm{'ldapport'}");
> 769 }


Hi Carl

(Please bottom-post your replies so that long threads like this one remain
comprehensible. Thanks.)

First of all, display the contents of @INC using

print "$_\n" foreach @INC;

then each element will appear on a separate line and the output will be more
readable.

Now you haven't understood what I wrote. Perl is looking for a file

Mozilla/LDAP/Conn.pm

in any of the paths in @INC. So with the 'use lib' line you have it will look
for

/usr/perl5/5.6.1/lib/Mozilla/LDAP/Conn.pm
/usr/iplanet/perl5/lib/site/Mozilla/LDAP/Mozilla/LDAP/Conn.pm
/usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/Mozilla/LDAP/Conn.pm
/usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP/Mozilla/LDAP/Conn.pm
* /usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/Conn.pm

yet according to your original post, Conn.pm exists at all of

/usr/perl5/5.6.1/lib/Conn.pm
/usr/iplanet/perl5/lib/site/Mozilla/LDAP/Conn.pm
* /usr/ds/v5.2/nsPerl5.005_03/lib/site/Mozilla/LDAP/Conn.pm
/usr/ds/v5.2/nsPerl5.006_01/lib/site/Mozilla/LDAP/Conn.pm

none of which exist except the one I've marked, which Perl should find if your
program and the locations of the module are as you say, so please check them.

The first of these is useless because it doesn't have Mozilla/LDAP in the path.
But the others are fine as long as you have ONE of

use lib qw(/usr/iplanet/perl5/lib/site);
use lib qw(/usr/ds/v5.2/nsPerl5.005_03/lib/site);
use lib qw(/usr/ds/v5.2/nsPerl5.006_01/lib/site);

As I said before, which one you choose depends on how your system is put
together and where other similar libraries are held.

I hope this helps.

Rob
Paul Lalli

2007-02-26, 3:59 am

On Feb 25, 11:36 am, rob.di...@350.com (Rob Dixon) wrote:
>


>
>
>
>


> Now you haven't understood what I wrote.


Perhaps, but you haven't understood the error message the OP is
reporting. It is not complaining that it can't find the module. It
is complaining that the module was never ATTEMPTED to be loaded.

The OP commented out the 'use' line in his above code, and didn't have
it all in the original. It needs to be uncommented


Paul Lalli

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com