in reply to [SOLVED] Perl randomly couldn't locate a Perl module in @INC

Hello Bravo_t, and welcome to the Monastery!

The behaviour of the lib pragma is documented here.

I'm surprised to know Perl will "recursively" add sub directories into @INC if they have some particular names.

Yes, but those names are specific to your current version of Perl. For example, I currently get:

16:54 >perl -V:archname archname='MSWin32-x64-multi-thread'; 16:54 >perl -V:version version='5.22.0'; 16:54 >

So if I have:

use lib "./some/path/perl";

and if there is a directory ./some/path/perl/5.22.0 on my system, then my @INC will contain:

"./some/path/perl/5.22.0", "./some/path/perl", ...

But if I also have a directory ./some/path/perl/5.8.0, that will not be added to @INC because it doesn’t correspond to the version of my current Perl.

So, my best guess is that the apparently random behaviour you are seeing is actually due to you calling the script with different versions of the Perl executable.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Perl randomly couldn't locate a Perl module in @INC
by Bravo_t (Acolyte) on Jul 23, 2015 at 08:06 UTC

    Thanks for your reply and sharing with me the doc.

    I will see if it's caused by the version of Perl interpreter, Thanks.