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).
In reply to Re^6: Recursively walk up a directory tree
by 1nickt
in thread Recursively walk up a directory tree
by 1nickt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |