What's the difference between use, unshift and PERL5LIB when adding/including module path?
A.
use lib - is a compile time inclusion. Try this example:
#! /usr/bin/perl -w
use strict;
print "@INC\n";
use lib '/home/kdranjan/Perl/Dynamic';
Print "@INC\n";
Run it and it will display: (Both are same because added path was included at compile time)
---------------------------
- /home/kdranjan/Perl/Dynamic /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 .
- /home/kdranjan/Perl/Dynamic /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 .
==========================================================
unshift - is a run time inclusion.
Modify previous script a bit like this:
---------------------------------------
#! /usr/bin/perl -w
use strict;
print "@INC\n";
unshift(@INC, '/home/kdranjan/Perl/Dynamic');
print "@INC\n";
- /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 .
- /home/kdranjan/Perl/Dynamic /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 .
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment