How do you use a variable in lib Path?

后端 未结 3 1804
离开以前
离开以前 2021-02-19 14:43

I would like to use the $var variable in lib path.

my $var = \"/home/usr/bibfile;\"

use lib \"$var/lib/\";

However when I do th

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-19 15:13

    You can't, because the use directive is evaluated at compile time, while other variables are evaluated at runtime.

    If your lib is located somewhere relative to your original script, you can use the standard module FindBin:

    # $Bin from FindBin is the directory of the original script
    use FindBin;
    use lib "$FindBin::Bin/path/to/bib";
    use MyModule;
    

提交回复
热议问题