I would like to use the $var variable in lib path.
my $var = "/home/usr/bibfile;"
use lib "$var/lib/";
However when I do this it throws an error.
I'd like to use use lib "$var/lib/";
instead of use lib "/home/usr/bibfile/lib/";
.
How can I assign a variable, so that it can be used in the setting of lib modules?
To add a path to the PATH environment variableIn the System dialog box, click Advanced system settings. On the Advanced tab of the System Properties dialog box, click Environment Variables. In the System Variables box of the Environment Variables dialog box, scroll to Path and select it.
The PATH variable is an environment variable containing an ordered list of paths that Linux will search for executables when running a command. Using these paths means that we don't have to specify an absolute path when running a command.
The LIBPATH environment variable tells the shell on AIX® systems which directories to search for dynamic-link libraries for the INTERSOLV DataDirect ODBC Driver. You must specify the full path name for the directory where you installed the product.
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 ...
];
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