I tried to run a perl script inside my other shell script but I have faced the following snag:
Can't locate new.pm in @INC (@INC contains: /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl
I have specifically set the path where the additional local perl script, i.e, "new.pm" in my Perl script (test.pl) but the error still appears. (perl -V) shows the path of my local Perl. I have further also set the path of my "new.pm" in my profile file using the command "PERL5LIB".
However, when I run the script on a command line as:
./test.pl
it works like a charm.
PS. The she-bang line is properly set. PSS. Platform: linux, OS_vers=2.6.32-5-amd64
There are multiple ways to do this, but I don't think setting the path is one of them. If "new.pm" is in the /my/lib
directory, try any of these:
perl -I/my/lib script-that-calls-new.pl
or
use lib '/my/lib'; ## add this before "use new;"
or
BEGIN { push @INC, '/my/lib'; }; ## same as "use lib" example
or
export PERL5LIB=/my/lib:$PERL5LIB
The path tells your shell where to look for executables. The examples above all tell perl where to find libraries.