Perlのインストール済みモジュール一覧

以下のスクリプトを作成して実行する

# perl modlist.pl

  • modlist.pl
    use strict;
    
    my %mod_list;
    
    listup($_) for grep {$_ ne '.'} @INC;
    print "$_\n" for sort keys %mod_list;
    
    sub listup {
    my ($base, $path) = @_;
    (my $mod = $path) =~ s!/!::!g;
    
    opendir DIR, "$base/$path" or return;
    my @node = grep {!/^\.\.?$/} readdir DIR;
    closedir DIR;
    
    foreach (@node) {
    if (/(.+)\.pm$/) { $mod_list{"$mod$1"} = 1 }
    elsif (-d "$base/$path$_") { listup($base, "$path$_/") }
     }
    }

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS