Wednesday, 14 August 2019

What is the use of @INC and how many methods to change it in Perl?


Deafult @INC is constructed with binaries, which can be listed using "env -i perl -V" and all thease binaries will be placed under common directory, for the binary compilation of our custom modules so we need to add the path for execution as well as compilation
below commands adds the path with @INC

To list Environmental variable PERL5LIB (or PERLLIB):perl -v

Method1:

perl -I /my/moduledir your_script.pl

Method2:

#!/usr/local/bin/perl -w -I /my/moduledir

Method3:

use lib ("/dir1", "/dir2");

Method4:

command line:
perl -Mlib=/dir1,/dir2

Method5:

unshift @INC, $dir,push @INC, $dir



kaavannan perl blogspot

Labels: , , , , , , ,