Does Perl look in .
(the current directory) for modules?
I can't directly install a module and I think I could copy it into the local directory. Is this true?
perl -V
will print out various properties about your Perl installation, including the default @INC
. You should notice a .
in there: yes, the current working directory is searched for modules by default.
(If not, you can use environment variables PERL5LIB
or PERLLIB
, or -I
on the command line, or add a sitecustomize.pl
to perl -V:sitelib
.)
In response to Cameron and tchrist's discussion in the comments to ephemient's answer.
You may use this snippet to use modules in the same directory as the script, even if the script is executed while in another directory.
use Cwd 'abs_path';
use File::Basename;
use lib dirname( abs_path $0 );
It should work in all cases and on all OSes. (Source: http://use.perl.org/~Aristotle/journal/33995)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With