How can I check if a Perl module is installed on my system from the command line?

前端 未结 10 1153
旧巷少年郎
旧巷少年郎 2020-12-07 14:33

I tried to check if XML::Simple is installed in my system or not.

perl -e \'while (<@INC>) { while (<$_/*.pm>) { print \"$_\\n\"; } }\'
         


        
10条回答
  •  感情败类
    2020-12-07 15:15

    If you want to quickly check if a module is installed (at least on Unix systems, with Bash as shell), add this to your .bashrc file:

    alias modver="perl -e\"eval qq{use \\\$ARGV[0];\\\\\\\$v=\\\\\\\$\\\${ARGV[0]}::VERSION;};\ print\\\$@?qq{No module found\\n}:\\\$v?qq{Version \\\$v\\n}:qq{Found.\\n};\"\$1"
    

    Then you can:

    => modver XML::Simple
    No module found
    
    => modver DBI
    Version 1.607
    

提交回复
热议问题