Perl Module Tips
This a bit of pre-emptive blogging, for the next time I forget. Those of you with stronger Perl-fu than I already know these things.
How to check if a module is installed:
No output indicates success : perl -MMODULENAME -e1
For example: perl -MHTML::Embperl -e1
How to check the version number of an installed module:
Assumes the module uses $VERSION, but then, most CPAN modules do) : perl -MMODULENAME -e’print “$MODULENAME::VERSION\n”;’
For example: perl -MHTML::Embperl -e’print “$HTML::Embperl::VERSION\n”;’
How to determine where a module is installed:
Lists every dir used by the module, including man pages, etc. Should be entered on one line. :
perl -MExtUtils::Installed
-e'$,="\n";print ExtUtils::Installed->new()->directories("MODULENAME")," "'
For example:
perl -MExtUtils::Installed
-e'$,="\n";print ExtUtils::Installed->new()->directories("HTML::Embperl")," "'
This technique relies on ExtUtils::Installed, which is part of the standard Perl distro these days.
Both comments and pings are currently closed.
http://www.flashesofpanic.com
Oh, that first one saved me some time this afternoon. (Time I’m using to comment here, but oh well…)
Jason, thank you very much for the tip “How to check the version number of an installed module”! I needed it the check that I met all the CPAN module requirements before upgrading my SpamAssassin server.