How do you use a variable in lib Path?
Not sure about what you're trying to accomplish, but seems like a task for FindBin::libs:
my $var;
BEGIN { $var = "/home/usr/bibfile" };
use FindBin::libs "Bin=$var", "base=lib";
Variables work fine in use lib
, well, just like they do in any string. However, since all use
directives are executed in BEGIN
block, your variable will be not yet initialized at the moment you run use
, so you need to put initialization in BEGIN
block too.
my $var;
BEGIN { $var = "/home/usr/bibfile"; }
use lib "$var/lib/";
use Data::Dumper;
print Dumper \@INC;
Gives:
$VAR1 = [
'/home/usr/bibfile/lib/',
# ... more ...
];