我对perl的一个持续痛苦是当我需要尝试在我的文件系统中找到特定模块的位置以便我可以自己检查它时;我最终必须首先找出我的@INC
路径是什么,然后必须深入挖掘它直到找到模块。幸运的是,我不是唯一一个;有人在PerlMonks上发布了这个问题的解决方案:
更新:显示的原始列表无效!以下是从对原始PM帖子的评论中获得的,可以,并且是我现在正在使用的。
#!/usr/bin/perl -w use strict; use File::Spec::Functions qw/catfile/; my @loaded = grep { eval "require $_"; !$@ ? 1 : ($@ =~ s/(@INC contains: Q@INCE)//, warn ("Failed loading $_: $@"), 0); } @ARGV; my @pm = map catfile(split '::') . (/.pmz/ ? '' : '.pm'), @loaded; print "@INC{@pm}n"; __END__ =pod =head1 NAME whichpm - lists real paths of specified modules =head1 SYNOPSIS editor `whichpm Bar` =head1 DESCRIPTION Analogous to the UN*X command which. =cut
只需将它放在您的$PATH
中,然后开始吧!