[英]Perl: How to avoid adding current directory to module include path?
I'd like to override some perl modules from a perl tool installed via conda.我想从通过 conda 安装的 perl 工具覆盖一些 perl 模块。 However, I cannot overwrite it because perl always prepends its own module directories:
但是,我无法覆盖它,因为 perl 总是预先添加自己的模块目录:
/opt/anaconda/envs/vep-99/share/ensembl-vep-99.2-0/modules
/opt/anaconda/envs/vep-99/share/ensembl-vep-99.2-0
/home/user/.local/lib/perl5/lib/perl5/x86_64-linux-thread-multi
/home/user/.local/lib/perl5/lib/perl5
/opt/anaconda/envs/vep-99/lib/site_perl/5.26.2/x86_64-linux-thread-multi
/opt/anaconda/envs/vep-99/lib/site_perl/5.26.2
/opt/anaconda/envs/vep-99/lib/5.26.2/x86_64-linux-thread-multi
/opt/anaconda/envs/vep-99/lib/5.26.2
.
I now did a very ugly hack which simply changes the working directory for perl:我现在做了一个非常丑陋的 hack,它只是更改了 perl 的工作目录:
#!/bin/bash
SCRIPT="${SCRIPT:-vep}"
SCRIPT_DIR="$(dirname $(realpath $(which $SCRIPT)))"
export PERL5LIB="$PERL5LIB:$SCRIPT_DIR:$SCRIPT_DIR/modules"
cd /
cat $(which $SCRIPT) | perl $@
This results in the following @INC:这会产生以下@INC:
//modules
/
/home/user/.local/lib/perl5/lib/perl5/x86_64-linux-thread-multi
/home/user/.local/lib/perl5/lib/perl5
/opt/anaconda/envs/vep-99/share/ensembl-vep-99.2-0
/opt/anaconda/envs/vep-99/share/ensembl-vep-99.2-0/modules
/opt/anaconda/envs/vep-99/lib/site_perl/5.26.2/x86_64-linux-thread-multi
/opt/anaconda/envs/vep-99/lib/site_perl/5.26.2
/opt/anaconda/envs/vep-99/lib/5.26.2/x86_64-linux-thread-multi
/opt/anaconda/envs/vep-99/lib/5.26.2
.
This technically works, but there is still /
, //modules
and .
这在技术上是可行的,但仍然有
/
, //modules
和.
in the include path.在包含路径中。 Is there a way to get rid of that?
有没有办法摆脱它?
It's the following that's adding those directories:以下是添加这些目录的内容:
export PERL5LIB="$PERL5LIB:$SCRIPT_DIR:$SCRIPT_DIR/modules"
Just remove or comment out that line.只需删除或注释掉该行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.