use lib '.';
jarich at perltraining.com.au
Wed Oct 2 20:54:27 CDT 2002
> > > Doesn't a Perl program automatically have access to programs
> > > in the current directory?
> Is the context such that '.' would ever be removed from @INC?
> That's the only reason I could see for "use lib '.'".
Nope pay attention to below. The @INC is searched in order.
> mryan at host:~> perl -e 'print join("\n", @INC), "\n"'
. is ONLY searched after everything else has been checked.
> mryan at host:~> perl -e 'use lib "."; print join("\n", @INC), "\n"'
Now . is checked first.
This means that if you've got your own version of CGI.pm (perhaps
because you can't get the sysadmin to upgrade theirs) and it's in the same
location as your script then your script will use your version. Now
usually it's recommended that you created a separate directory for all
your library files, but you get the idea.
A less obvious problem that this fixes is if you call a library after a
system module you didn't know existed (for example "Config.pm"). If
use lib '.';
to your scripts you'll safely use YOUR Config.pm and all will be good. If
you don't add the use lib, you'll start to wonder why your Config.pm isn't
("`-''-/").___..--''"`-._ | Jacinta Richardson |
`6_ 6 ) `-. ( ).`-.__.`) | Perl Training Australia |
(_Y_.)' ._ ) `._ `. ``-..-' | +613 9354 6001 |
_..`--'_..-_/ /--'_.' ,' | contact at perltraining.com.au |
(il),-'' (li),' ((!.-' | www.perltraining.com.au |
More information about the Melbourne-pm