Is there a smart way to detect whether a certain Perl module has been installed in your system? My old sutpid way is to write a Perl script in which the only thing I do is just to use the module. If nothing croaks when I run the detect script, then I know the module has been installed, although I still don't know which version and where the module has been installed .
thanks in advance.
Type perl -v on a command line to find out which version. ActiveState Perl has binary distributions of Perl for many platforms. This is the simplest way to install the latest version of Perl.
You need to use instmodsh (interactive inventory for installed Perl modules) command to find out what modules already installed on my system. instmodsh command provides an interactive shell type interface to query details of locally installed Perl modules.
Normally, perl will be in your shell's path. It can often be found lurking in /usr/bin or /usr/local/bin. Use your system's find or locate command to track down perl if it doesn't appear in your command path.
Something like:
perl -MModule -e 'print "$Module::VERSION\n"' 2>/dev/null || echo "Not installed"
would give you the version of a given module, or tell you it isn't installed. Usage would look like:
perl -MXML::Parser -e 'print "$XML::Parser::VERSION\n"' 2>/dev/null || echo "Not installed"
To find the module path, you could examine @INC
to find possible locations, or you could perhaps look into perlwhich. There is also pmpath from pmtools.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With