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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Can't find xxx:zzz.pm in @INC in external file

 



brileigh
New User

Sep 20, 2010, 2:22 PM

Post #1 of 3 (1112 views)
Can't find xxx:zzz.pm in @INC in external file Can't Post

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


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

use strict ;
use warnings ;
use FindBin ;

use lib 'C:\blah blah\MyLib' ;
#require "$FindBin::Bin/mylibs.pm" ;
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
mylibs.pm is in the same folder as the above script. it contains

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

The error shows:

Code
Can't locate xxx/zzz.pm 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 mylibs.pm

Therefore I know that mylibs.pm 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/mylibs.pm" ;' 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
Brian


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


BillKSmith
Veteran

Sep 20, 2010, 3:27 PM

Post #2 of 3 (1107 views)
Re: [brileigh] Can't find xxx:zzz.pm 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,
Bill


brileigh
New User

Sep 20, 2010, 3:33 PM

Post #3 of 3 (1106 views)
Re: [BillKSmith] Can't find xxx:zzz.pm 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.

Thanks
Brian

 
 


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

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