LoginSignup
2
0

More than 3 years have passed since last update.

【perl】モジュール一覧

Last updated at Posted at 2019-09-01

その1:モジュール名のみ

perl -MExtUtils::Installed -le 'print for ExtUtils::Installed->new->modules'

以下とほぼ等価

#!/usr/bin/perl
use strict;
use ExtUtils::Installed;  # -MExtUtils::Installed
for (ExtUtils::Installed->new->modules) {
  print;
  print "\n"; # -l
}

その2:モジュール名とバージョン

perl -MExtUtils::Installed -le 'print "$_\t".eval("use $_(); \$$_\:\:VERSION") for ExtUtils::Installed->new->modules'

以下とほぼ等価

#!/usr/bin/perl
use strict;
use ExtUtils::Installed;  # -MExtUtils::Installed
for (ExtUtils::Installed->new->modules) {
  print;
  print "\t";
  print eval "use $_();".'$'.$_.'::VERSION';
  print "\n"; # -l
}

その3:モジュール名とバージョンとインストール日時

perldoc -tT perllocal |
perl -nle '$d=$1,$m=$2 if /\s+(.*): "Module" (.*)/;print "$m\t$1\t$d" if /"VERSION: (.*)"/'

perldoc -tT perllocal を使用。

$ perldoc -tT perllocal
()
  Sun Sep  1 01:53:32 2019: "Module" ExtUtils::MakeMaker
    *   "installed into: xxxxxxxxxxxxxxxxxxxxxxxxxxxx"

    *   "LINKTYPE: dynamic"

    *   "VERSION: 7.36"

    *   "EXE_FILES: bin/instmodsh"

()

以下とほぼ等価

#!/usr/bin/perl
use strict;
my $cmd = "perldoc -tT perllocal";
open PL, "$cmd |" or die "Can't exec '$cmd': $!";
my ($m,$v,$d);
while(<PL>) {
  $d=$1,$m=$2 if /\s+(.*): "Module" (.*)/;
  print "$m\t$1\t$d\n" if /"VERSION: (.*)"/;
}
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0