CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Can't find in @INC in external file


New User

Sep 20, 2010, 2:22 PM

Post #1 of 3 (1131 views)
Can't find in @INC in external file Can't Post

I have been coding Perl a while, and I am stuck on something that should be very simple.
I have this code:

#!c:\perl\bin\perl.exe -w 

use strict ;
use warnings ;
use FindBin ;

use lib 'C:\blah blah\MyLib' ;
#require "$FindBin::Bin/" ;
print @INC ;
use xxx::zzz ;

then the code works, and the @INC shows
C:\blah blah\MyLib C:\Perl\site\lib C:\Perl\lib .
If I rem the 'use lib ...' and unrem the 'require ...' I get a problem is in the same folder as the above script. it contains

#!c:\perl\bin\perl.exe -w  
use strict ;
use warnings ;
use lib 'C:\blah blah\MyLib' ;

The error shows:

Can't locate xxx/ in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib .)

if I then also rem out the 'use xxx::zzz'
then I do not get an error and the @INC shows what I expect:
C:\blah blah\MyLib C:\Perl\site\lib C:\Perl\lib .
even though it was set in the

Therefore I know that is being executed (plus I have printed from there to be sure) and it is setting @INC but when it comes to using a module which should be findable in the paths in the @INC its not working. It does not seem to be looking at the same @INC

I have tried using 'do "$FindBin::Bin/" ;' instead of require with the same outcome.

Does anyone have any idea might be going wrong.

By the way, the reason for not just leaving the use lib pragma in the main code is that I will hae numerous scripts which need portability to different development machines and servers.

Many thanks

(This post was edited by brileigh on Sep 20, 2010, 2:50 PM)


Sep 20, 2010, 3:27 PM

Post #2 of 3 (1126 views)
Re: [brileigh] Can't find in @INC in external file [In reply to] Can't Post

You may be able to use the environmental variable PERL5LIB rather than the lib pragma.

Refer to the Environment section of perldoc perlrun. This probably will not solve all your module problems, but it may help.
Good Luck,

New User

Sep 20, 2010, 3:33 PM

Post #3 of 3 (1125 views)
Re: [BillKSmith] Can't find in @INC in external file [In reply to] Can't Post

Thanks Bill,
Although that would probably make it more difficult to move around onto other systems.

More concerning though is the reason it is happening. It means fundamentally I am misunderstanding something that should be straightforward. I would prefer to get better understanding of what I did than perhaps the workaround.



Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives