Let's say there are three paths in @INC: path1, path2 and path3. Under each of these paths, there is a module named foo.pm. If I now load foo.pm in my script via use foo;, which of the foo.pms is actually going to be loaded? Or in other words, what is perl's search order for paths in @INC?
perldoc -v %INC shows which path was chosen:
use Data::Dumper;
print Dumper(\%INC);
Or...
perl -Mfoo -e 'print $INC{"foo.pm"}'
require shows some psuedo-code which implies the search order:
foreach $prefix (@INC) {
}
Thus, path1 would be searched first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With