Who makes it into @INC first?

Perl finds modules by looking through the list of directories in @INC. There are many ways to add paths to that array, and although I’ve used all of them at some point, I’ve never quite thought about what happens when I use all of them together.

Remember that Perl uses the first matching module name it finds then
stops looking. It does not have a designed way to determine a best match and newest match or anything fancy. Whatever it finds first is the winner. This also means that someone could add paths to @INC and force your program to run their version of a module, even maliciously. This is something I write about in the “Secure Programming Techniques” chapter of Mastering Perl.

Continue reading “Who makes it into @INC first?”