For Programmers: Free Programming Magazines  


Home > Archive > PERL Programming > April 2004 > ARG! Problem Using package









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 ARG! Problem Using package
Keg

2004-04-27, 12:56 pm

I am trying to write a package. I use the package but get the
following error:
Can't locate Myprogd/SysBoot.pm in @INC (@INC contains:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0) at
../myprogd line 3.

Myprogd is in this directory: /var/scripts. SysBoot.pm is in the
/var/scripts/Myprogd directory.

In Myprogd is have this line:

use Myprogd::SysBoot.pm;

Here is the beginning of SysBoot.pm:
#!/usr/bin/perl

package Myprogd::SysBoot;
use strict;
......
1;


What am I doing wroing here? This code is almost identical to code
taken from a perl book. (written by Larry himself)

Thanks
-keg
Gunnar Hjalmarsson

2004-04-27, 1:54 pm

Keg wrote:
> I am trying to write a package. I use the package but get the
> following error:
> Can't locate Myprogd/SysBoot.pm in @INC


<snip>

> Myprogd is in this directory: /var/scripts. SysBoot.pm is in the
> /var/scripts/Myprogd directory.
>
> In Myprogd is have this line:
>
> use Myprogd::SysBoot.pm;


Sometimes the current directory is included in @INC and sometimes not.
In this case it seems not to be included, so try this

use lib '.';

before "use"ing your module.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Gunnar Hjalmarsson

2004-04-27, 1:55 pm

Gunnar Hjalmarsson wrote:
> Keg wrote:
>
> Sometimes the current directory is included in @INC and sometimes not.
> In this case it seems not to be included, so try this
>
> use lib '.';
>
> before "use"ing your module.


Err.. Another thing is that when "use"ing a module, the file extension
shall not be included:

use Myprogd::SysBoot;

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Keg

2004-04-29, 5:13 pm

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<c6m1ud$dqet8$1@ID-184292.news.uni-berlin.de>...
> Gunnar Hjalmarsson wrote:
>
> Err.. Another thing is that when "use"ing a module, the file extension
> shall not be included:
>
> use Myprogd::SysBoot;

Yea I made a typo above, I was actually using that. I managed to get
this to work using the PERL5LIB env variable but now all the sudden it
is not working.

Anyone ever have issues with PERL5LIB? I explicitly set this as
follows:

#!/bin/bash

PERL5LIB="."
export PERL5LIB

echo "DEBUG: PERL5LIB=${PERL5LIB}"
../myProgd -c myProgd.conf
exit 0;

Here is what I get when I run the script:
Starting /root/Myprogd: Can't locate Myprogd::SysBoot.pm in @INC (@INC
contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0) at
/root/Myprogd line 3.
BEGIN failed--compilation aborted at /root/Myprogd line 3.

Yesterday I was prepending '.' to the @INC array as the documentation
suggesats. Oddly, today that is not working.

Is there a knock down rock-solid way of modifying the @INC array"?

Thx,
keg
Sherif Zaroubi

2004-04-29, 5:13 pm

Check out
use lib ();

use lib ('../');


On 29 Apr 2004 06:56:09 -0700, Keg <rhugga@yahoo.com> wrote:

> Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message
> news:<c6m1ud$dqet8$1@ID-184292.news.uni-berlin.de>..
> Yea I made a typo above, I was actually using that. I managed to get
> this to work using the PERL5LIB env variable but now all the sudden it
> is not working.
>
> Anyone ever have issues with PERL5LIB? I explicitly set this as
> follows:
>
> #!/bin/bash
>
> PERL5LIB="."
> export PERL5LIB
>
> echo "DEBUG: PERL5LIB=${PERL5LIB}"
> ./myProgd -c myProgd.conf
> exit 0;
>
> Here is what I get when I run the script:
> Starting /root/Myprogd: Can't locate Myprogd::SysBoot.pm in @INC (@INC
> contains: /usr/lib/perl5/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/5.8.0
> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0) at
> /root/Myprogd line 3.
> BEGIN failed--compilation aborted at /root/Myprogd line 3.
>
> Yesterday I was prepending '.' to the @INC array as the documentation
> suggesats. Oddly, today that is not working.
>
> Is there a knock down rock-solid way of modifying the @INC array"?
>
> Thx,
> keg




--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Gunnar Hjalmarsson

2004-04-29, 5:13 pm

Keg wrote:
> Yesterday I was prepending '.' to the @INC array as the
> documentation suggesats. Oddly, today that is not working.
>
> Is there a knock down rock-solid way of modifying the @INC array"?


Full path, I suppose:

use lib '/var/scripts';

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Sponsored Links







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

Copyright 2008 codecomments.com