Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Can't locate Test/ in @INC

by taint (Chaplain)
on Dec 27, 2013 at 16:56 UTC ( #1068543=note: print w/replies, xml ) Need Help??

in reply to Can't locate Test/ in @INC

Greetings, zuverlassig.

As a rule, I'd have to say toolic is right. I'm inclined to think you might be experiencing a namespace-clash. I don't suppose you're calling the lib relative to your script, are you? It would make it easier to diagnose, implement. In any case, given that you're using two Modules with the same name, and that they generally have a PACKAGE declaration at, or near the top. How are yours defined? In other words; can you post the declarations you're using in your JSON modules? eg;

package JSON;
Given that traditionally the double-colon is used as a path separator. I suspect you're declarations are incorrect; Test::JSON assumes Test/JSON


UPDATE: Given you didn't share the actual error. I don't suppose it (Perl) was trying to find Test/Test/JSON, was/did it?

λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH

Replies are listed 'Best First'.
Re^2: Can't locate Test/ in @INC
by zuverlassig (Novice) on Dec 27, 2013 at 17:34 UTC
    These are the package declarations: for the first:- package JSON; for the other:- package Test::JSON; Now, I checked using print($INC{""}, "\n"); to find out which it was using. It turns out tht it uses, /usr/dir/packages/perl/perl-5.8.8/lib/site_perl/5.8.8/ and after I try to use only a specific method, it gives me this error: Can't locate object method "is_valid_json" via package "Test::JSON" (perhaps you forgot to load "Test::JSON"?)
      That's why I indicated that using a directory relative would make it easier to diagnose/implement.

      If both of your custom JSON modules declare

      package JSON;
      You should, as toolic initially asserted, be able to use
      use lib '/abc/xyz';
      use lib ('/abc/xyz');
      use JSON; use Test::JSON
      because as I noted earlier; the double-colon is a path/directory separator. Meaning; Test::JSON == Test/JSON.

      You might also try

      use lib '/abc/xyz/';
      as that negates the need to preface a slash before your custom modules.

      In any case; you must ensure that the path to your custom JSON modules preceeds (is before) your system Perl module path.
      That's why you see reference to conflicts within the system's perl, in the latest error you quoted.


      λɐp ʇɑəɹ⅁ ɐ əʌɐɥ puɐ ʻꜱdləɥ ꜱᴉɥʇ ədoH

        Thanks Chris, that worked! I cant believe what a stupid mistake I was making. And yeah toolic was right.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1068543]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2018-05-23 02:06 GMT
Find Nodes?
    Voting Booth?