in reply to Re^2: How to use a module without installing it?
in thread How to use a module without installing it?

Hi,

I tried your technique for the module I needed - let's call it "A::B".
I pasted the A::B module above my code, inside curly braces {}
The "A::B" code "require"s the parent code "A", which I pasted above it, inside curly braces {}
and the "A" code "require"s code "A::C", which I pasted above it, inside curly braces {}

Now I get the error message:

Can't locate A/C.pm in @INC

Any ideas?
  • Comment on Re^3: How to use a module without installing it?

Replies are listed 'Best First'.
Re^4: How to use a module without installing it?
by almut (Canon) on Aug 04, 2009 at 21:15 UTC

    If I'm understanding you correctly, you still have a require (or use) in your code — at least that's what the error message "Can't locate..." would suggest.

    Once you have a module's code pasted into the main script, there's no longer any need to require it (i.e. load it from an external file), as it's already there... So just remove or comment out the respective require/use instructions.

      Please correct me if I'm wrong, I never tried it myself...

      ...but use X implies to require X and to call X->import(LIST), so certainly you can comment out the require, but you still need to import!

      see use

      Cheers Rolf

        ... but you still need to import!

        That's correct — in case you actually want to import anything (or need to pass whatever parameters to the module's import method; or the module insists on having its import method called for some other reason).  OTOH, with many modules (especially OO-style ones) there's no need to import stuff, so there's a good chance you'd get away without calling import...  (I figured the OP would come back in case of problems :)