Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the version and location of an installed Perl module?

Tags:

module

perl

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.

like image 942
Haiyuan Zhang Avatar asked Dec 17 '09 07:12

Haiyuan Zhang


People also ask

How do I tell what version of perl I have installed?

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.

How do I know which perl modules are installed Linux?

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.

How do I find my perl path in Linux?

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.


1 Answers

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.

like image 194
DMI Avatar answered Sep 30 '22 18:09

DMI