Skip to content

Instantly share code, notes, and snippets.

@jyap808
Created March 4, 2015 19:59
Show Gist options
  • Save jyap808/58c7ad9fbec3b44984e0 to your computer and use it in GitHub Desktop.
Save jyap808/58c7ad9fbec3b44984e0 to your computer and use it in GitHub Desktop.
Perl - Check a module is installed

If you want to quickly check if 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

Via: http://stackoverflow.com/a/1039261

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment