I saw this sort of setup in all test files in this distribution:
BEGIN {
if (-d "lib") {
use lib "./lib";
} elsif (-d "../lib") {
use lib "../lib";
}
}
This makes no sense because use executes at compile time, so this code is equivalent to:
BEGIN {
use lib "./lib";
use lib "../lib";
if (-d "lib") {
} elsif (-d "../lib") {
}
}
In other words, this whole block could be replaced by use lib "./lib", "../lib"; without changing its functionality.
On the other hand, a working -d check could be implemented as
BEGIN {
require lib;
if (-d "lib") {
lib->import("./lib");
} elsif (-d "../lib") {
lib->import("../lib");
}
}
or simply
use lib (
-d "lib" ? "./lib" :
-d "../lib" ? "../lib" :
()
);
or perhaps even
use lib grep { -d } qw(./lib ../lib);
I saw this sort of setup in all test files in this distribution:
This makes no sense because
useexecutes at compile time, so this code is equivalent to:In other words, this whole block could be replaced by
use lib "./lib", "../lib";without changing its functionality.On the other hand, a working
-dcheck could be implemented asor simply
or perhaps even