I use custom modules in my scripts and must store them outside the Perl directory lib. Therefore, in Perl ( *.pl) scripts, I use the following block to include them in @INC:
BEGIN {
use FindBin qw($Bin);
push @INC, "$Bin/../ModulesFolder1";
push @INC, "$Bin/../ModulesFolder2";
}
But I also have to use modules inside my other Perl ( *.pm) modules , and as far as I understand, it FindBinworks only for scripts. Therefore, I change this block to:
BEGIN {
push @INC, catdir( dirname( $INC{'ThisModule.pm'} ), qw( .. ModulesFolder1 ) );
push @INC, catdir( dirname( $INC{'ThisModule.pm'} ), qw( .. ModulesFolder2 ) );
}
This works, but with a little problem. I have the code in Eclipse with the EPIC plugin and "if you have something in the BEGIN block that causes the compiler to abort prematurely, it will not report EPIC syntax errors" , so I will lose the Perl syntax check in the modules.
So, with FindBin(in scripts) I do not need to use any functions (for example catdir) in the block BEGIN{}, and the syntax checking of the following code is performed correctly. In addition, I would not want to change environment variables (for example, PERL5LIB) so that I could use scripts on the computers of my colleagues without any additional preparations.
Perl , EPIC ? , , ?