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.
|