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

use FindBin... use lib $... use File::FindLib... Its like a prerequisite just as any ... Nawmean?
  • Comment on Re^5: Recursively walk up a directory tree

Replies are listed 'Best First'.
Re^6: Recursively walk up a directory tree
by 1nickt (Canon) on Feb 11, 2018 at 11:25 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