Perl on Big Sur

The version of Perl on Big Sur does not support statements like "require". I get the error message


Can't locate sample2.pl in @INC (@INC contains: /Library/Perl/5.30/darwin-thread-multi-2level /Library/Perl/5.30 /Network/Library/Perl/5.30/darwin-thread-multi-2level /Network/Library/Perl/5.30 /Library/Perl/Updates/5.30.2 /System/Library/Perl/5.30/darwin-thread-multi-2level /System/Library/Perl/5.30 /System/Library/Perl/Extras/5.30/darwin-thread-multi-2level /System/Library/Perl/Extras/5.30) at gws_mcm_mc.pl line 20


where sample2.pl is a another script containing functions. What is the problem and how do I fix it?

Posted on Nov 20, 2021 6:00 PM

Reply

Similar questions

3 replies

Nov 21, 2021 10:38 AM in response to etresoft

Sorry, but this was not the problem. After doing some research here is what I found.


Perl 5.26.0 changed in @INC array such they removed the current working directory in the library search. The @INC array stores the paths in the library search. Later version of Perl removed the current working direct in the search for "security" reasons There are three ways to fix this.


  1. Put the Perl module - or file containing subroutines that you want to use, in one of the library directories included in @INC array
  2. Disable the secure mode and allow Perl to look in the working directly by typing "export PERL_USE_UNSAFE_INC=1;". This option is not recommended because Perl is supposed to get rid of the UNSAFE option in later versions.
  3. Include current working directory in @INC [push(@INC, ".");] within your script before using a use or require statement  


Thank you anyway for your time. Please post for other frustrated users.

Nov 21, 2021 11:58 AM in response to ASROOD

Perl is renowned, or infamous, for allowing all manner of different ways to use it. Apparently, as you seem to have discovered, modules don't need to have a ".pm" extension and even the "package" line can be omitted. But a script doesn't need to return a true value whereas a package does, even if you've given it a ".pl" extension.


That being said, there are still lots of best practices that one could choose to follow. But if the developers of Perl choose to make a change to disallow, by default, one particular bad practice, then I strongly recommend that you don't override their decision.


Perl is not broken and this does not need to be fixed.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Perl on Big Sur

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.