# Compiling using File::Spec using File::Basename there is a global variable called $some_path add to path $some_path/lib _Compilation complete_ # Running $some_path = dirname(File::Spec->rel2abs(__FILE__)); #### my $some_path; BEGIN { $some_path = "/my/path"; } use lib "$some_path/lib"; # Yeah, you don't even need the parenthesis, Perl is clever enough for you # Edit : thanks dave_the_m for the correction