2

I've installed Strawberry Perl v5.28.0 MSWin32-x64-multi-thread on windows 10. However, I noticed that it does not find module under the current directory and every time I run any script, I've to add current directory into the path.

perl -I . somescript.pl

This was not the case earlier. Is there a way to put the current directory in the path by default so I don't have to run with

perl -I .

Note: While browsing, I read somewhere(can't remember the link or website) that latest versions of Perl excluded a current directory from @INC for security reasons. But I'm trying to find a solution for a development machine.

Kiran Kyle
  • 99
  • 11

1 Answers1

1

It doesn't make sense to look in the current work directory. It often makes sense for a script to look for modules bundled with it, which is to say it sometimes makes sense to tell Perl to look for modules in a path relative to the location of the script. To that end, the script should include

use FindBin qw( $RealBin );

use lib $RealBin;   # or "$RealBin/lib" or "$RealBin/../lib", etc

If this is only for development, setting env var PERL5LIB might make more sense.

ikegami
  • 367,544
  • 15
  • 269
  • 518