Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^4: Recursively walk up a directory tree

by 1nickt (Canon)
on Feb 10, 2018 at 18:24 UTC ( [id://1208913]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Recursively walk up a directory tree
in thread Recursively walk up a directory tree

Yeah, its called a module.

Given that the purpose of finding the base directory is to be able to add the lib directory to @INC, how do you suggest such a module could be loaded?


The way forward always starts with a minimal test.
  • Comment on Re^4: Recursively walk up a directory tree

Replies are listed 'Best First'.
Re^5: Recursively walk up a directory tree
by Anonymous Monk on Feb 11, 2018 at 08:20 UTC

      In some simple cases using:

      use FindBin '$RealBin'; use lib "$RealBin/../../../lib"; # or whatever
      is acceptable, even if completely inelegant. But usually it's a mistake since it means you can't move your test or script to another level in the tree without breaking it. As projects expand you often do move sub-directories around. The relative path also has to be different for different sub-directory levels, so it requires thought and maintenance even before you move anything. Hence the search for something better.

      Update: I was not familiar with tye's File::FindLib. It seems like it would be useful for "clean" well-designed projects. Unfortunately many projects are not clean or well-organized, having evolved sometimes over years and many different development teams. In some cases there are lib/ sub-directories off non-root directories (eg <base>/t/lib/, and using use File::FindLib 'lib'; from a test file like <base>/t/foo/bar.t will find the first (wrong) one. (This is what led to the use of a marker file).


      The way forward always starts with a minimal test.
        Um... You're welcome? Didnt exactly expect either module to be the exact solution ... Drop a deuce or tres ... examples ... If you need help writing module or ?? .... Rename lib to testlib like findlib example? :D thoughts i have

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-23 22:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found