モジュールがインストールされている環境で、そのモジュールのパスを調べる方法がわかればよいと思って検索してみると、ありがたいことに、先人の方が居られました。
http://wizard-blue.hatenablog.jp/entry/20091029/1256743552
なるほど @INC を find すればよいですね。ドット(.)の find には気をつけたほうがよいって、なんと親切な補足と思いました。ドット(.)の下に大量にファイルがあるという状況は、よくありそうですよね。ホームディレクトリとか。
man perlvar によると、-T オプションを使えば、ドット(.)が除外されるとありました。
@INC The array @INC contains the list of places that the "do EXPR",
"require", or "use" constructs look for their library files.
It initially consists of the arguments to any -I command-line
switches, followed by the default Perl library, probably
/usr/local/lib/perl, followed by ".", to represent the current
directory. ("." will not be appended if taint checks are
enabled, either by "-T" or by "-t".) If you need to modify
ということは、先人の方が書かれていたテクニックを若干変形して、次のようにすれば、ドット(.)を避けて検索できるようです。
[root@hoge ~]# perl -T -e 'map { print "$_\n" ; } @INC ;'
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5
※ドット(.)は含まれない
[root@hoge ~]# find `perl -T -e 'print "@INC" ;'` -name "Zlib.pm"
find: '/usr/local/lib64/perl5': そのようなファイルやディレクトリはありません
find: '/usr/local/share/perl5': そのようなファイルやディレクトリはありません
/usr/lib64/perl5/vendor_perl/Compress/Raw/Zlib.pm
/usr/lib64/perl5/vendor_perl/Compress/Raw/Zlib.pm
/usr/share/perl5/Compress/Zlib.pm
この出力を rpm -qf に渡すことで、そのモジュールを含む RPM を特定できました。
[root@hoge ~]# rpm -qf /usr/share/perl5/Compress/Zlib.pm perl-IO-Compress-2.061-2.el7.noarch [root@hoge ~]# uname -a Linux hoge 3.10.0-957.12.2.el7.x86_64 #1 SMP Tue May 14 21:24:32 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux [root@hoge ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core)/usr/share の下とは、ちょっと意外でした。/usr/lib64 の下かと思ってた。
0 件のコメント:
コメントを投稿