in reply to Re^5: Recursively walk up a directory tree
in thread Recursively walk up a directory tree
In some simple cases using:
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.use FindBin '$RealBin'; use lib "$RealBin/../../../lib"; # or whatever
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).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Recursively walk up a directory tree
by Anonymous Monk on Feb 11, 2018 at 12:20 UTC |