Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I think this is a fairly simple question, yet I can't find out how to do it. I have a bunch of scripts that are being executed via bash shell. I want to push an additional path to a perl lib into @INC before it executes. How do I do this? What is the syntax? I googled it but am having trouble finding the answer.

Thank you!

  • Comment on add perl path to INC in my shell script

Replies are listed 'Best First'.
Re: add perl path to INC in my shell script
by ikegami (Patriarch) on Jul 08, 2010 at 23:07 UTC
    perl -Idir ...
    perl -Mlib=dir ...
    PERL5LIB=dir"${PERL5LIB:+:$PERL5LIB}" perl ... PERL5LIB=dir"${PERL5LIB:+:$PERL5LIB}" script.pl ...
    export PERL5LIB=dir"${PERL5LIB:+:$PERL5LIB}" perl ... script.pl ...

    Reference: perlrun, lib

Re: add perl path to INC in my shell script
by Anonymous Monk on Jul 08, 2010 at 23:09 UTC
    $ perl -I" a b c d " -le"print for @INC" a b c d C:/perl/5.10.1/lib/MSWin32-x86-multi-thread C:/perl/5.10.1/lib C:/perl/site/5.10.1/lib/MSWin32-x86-multi-thread C:/perl/site/5.10.1/lib . $ set PERL5LIB=THE STUFF $ perl -I1 -I2 -I3 -I4 -le"print for @INC" 1 2 3 4 THE STUFF C:/perl/5.10.1/lib/MSWin32-x86-multi-thread C:/perl/5.10.1/lib C:/perl/site/5.10.1/lib/MSWin32-x86-multi-thread C:/perl/site/5.10.1/lib . $ perl -Mlib="blah blah blah" -le"print for @INC" blah blah blah THE STUFF C:/perl/5.10.1/lib/MSWin32-x86-multi-thread C:/perl/5.10.1/lib C:/perl/site/5.10.1/lib/MSWin32-x86-multi-thread C:/perl/site/5.10.1/lib .
    See perlrun for more
Re: add perl path to INC in my shell script
by suhailck (Friar) on Jul 09, 2010 at 03:28 UTC
    perl -le 'BEGIN { push @INC,"a"; } print for @INC'

    /etc/perl
    /usr/local/lib/perl/5.10.0
    /usr/local/share/perl/5.10.0
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.10
    /usr/share/perl/5.10
    /usr/local/lib/site_perl
    .
    a
    


    ~suhail