Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Wrong + Right = Even Worse

by LanX (Canon)
on Apr 04, 2014 at 14:45 UTC ( #1081154=note: print w/ replies, xml ) Need Help??


in reply to Wrong + Right = Even Worse

> Originally, the full paths were used in require, which constituted one of the obstacles to run the project locally.

You can also put a coderref-hook in front of @INC to catch and redirect all do and require.

You can apply the same technique for a life monitoring of the dependencies by logging the caller. This might help you migrate the projects.

Not sure about CPAN modules doing this, see Re: How to use @INC coderef hooks (perldoc wrong) and linked threads for demos.

Cheers Rolf

( addicted to the Perl Programming Language)


Comment on Re: Wrong + Right = Even Worse
Replies are listed 'Best First'.
Re^2: Wrong + Right = Even Worse (@INC sub)
by tye (Cardinal) on Apr 04, 2014 at 15:52 UTC
    You can also put a coderref-hook in front of @INC to catch and redirect all do and require.

    Not "all". It won't catch a require for an already-loaded module.

    - tye        

      One would need a private shadow %MY_INC within the catch-sub to handle it and keeping %INC clean.

      I'm aware this would cause problems with code accessing %INC directly, but I somehow doubt this legacy code base ever attempts to do such things.

      IMHO good enough for debugging.

      Cheers Rolf

      ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1081154]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (16)
As of 2015-07-07 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls