vinoth.ree has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am trying to set PERL5LIB environment variable in windows10 with multiple paths, like below, export PERL5LIB="${HOMEDRIVE}\\Perl64\\lib;${HOMEDRIVE}\\Perl64\\site\\lib" but the ':' character after the Drive is getting removed from the PERL5LIB value like looks like C \Perl64\lib;C \Perl64\site\lib and modules are not getting loaded.

Is it windows behavior to remove the ':' character? Actually its a common shell script will setup the environment before I invoke the actual bunch of perl scripts, otherwise I would have used use lib "Path" inside the script to load the modules.


All is well. I learn by answering your questions...

Replies are listed 'Best First'.
Re: Windows set PERL5LIB environment variable
by VinsWorldcom (Prior) on May 06, 2021 at 10:35 UTC

    Windows doesn't have export so I'm not sure what you're doing. Are you using the perl with Git for Windows and Git bash?

    I use Strawberry Perl and set my PERL5LIB in Control Panel => System => Advanced System Settings => Advanced => Environment Variables => User Variables. It is:

    C:\Users\Vinsworldcom\perl5\lib\perl

    If you want to set it only temporarily in a PowerShell (no one uses CMD.exe anymore these days):

    PS VinsWorldcom ~ > $env:PERL5LIB="C:\Users\VinsWorldcom\perl5\lib\per +l5" PS VinsWorldcom ~ > $env:PERL5LIB C:\Users\VinsWorldcom\perl5\lib\perl5

    I think you may be messing up syntax. Windows uses colon (:) for drive letters and semicolon (;) for path separators. Bash uses colon (:) for path separators and uses semicolon (;) as command separators. Seems you're trying to use Windows syntax in Bash paths. To set PERL5LIB it in Git bash, don't worry about the drive:

    export PERL5LIB=/Users/VinsWorldcom/perl5/lib/perl5

    or if you really need the drive letter, I think the following syntax works:

    export PERL5LIB=/C/Users/VinsWorldcom/perl5/lib/perl5

    Cheers.

      Yes, I have git bash, using git from windows, I am trying to run client side hooks written in perl. Whenever developer commit a code, we run 15 perl scripts separately to make sure the code is followed our coding standard.


      All is well. I learn by answering your questions...

        I understand now, but I think you *may* encounter issues. If your Git Bash is seeing the Git for Windows perl as the Perl to use and you're trying to add PERL5LIB for ActiveState Perl (assumed based on the Windows path I see), you better hope they are the same Perl version or that you're just referencing pure Perl modules in the PERL5LIB path you provide.

Re: Windows set PERL5LIB environment variable
by AnomalousMonk (Archbishop) on May 06, 2021 at 10:07 UTC

    Is there an export command in the Windows CLP? set works for me in Windows 8 (I can't test under Windows 10):

    Win8 Strawberry 5.30.3.1 (64) Thu 05/06/2021 5:57:09 C:\@Work\Perl\monks >set F FP_NO_HOST_CHECK=NO FTP_PASSIVE=1 Win8 Strawberry 5.30.3.1 (64) Thu 05/06/2021 5:57:12 C:\@Work\Perl\monks >set FOOBLE=%HOMEDRIVE%\Perl64\lib;%HOMEDRIVE%\Perl64\site\lib Win8 Strawberry 5.30.3.1 (64) Thu 05/06/2021 5:57:37 C:\@Work\Perl\monks >set F FOOBLE=C:\Perl64\lib;C:\Perl64\site\lib FP_NO_HOST_CHECK=NO FTP_PASSIVE=1


    Give a man a fish:  <%-{-{-{-<

      Both Windows versions should operate the same way with regard to this.