DEV Community

Johan Lindstrom
Johan Lindstrom

Posted on

What's the version of that installed Perl module?

Here's a neat trick to find out what version of a Perl module is installed.

Let's try with Carp.

perl -MCarp\ 99999 -e 1

Carp version 99999 required--this is only version 1.42.
BEGIN failed--compilation aborted.

The way this works is that we ask the runtime to load a very high version, and then wait for perl to apologize that it only has current version x, in this case 1.42.

Note the escaped space between the module and the version:
-MCarp\ 99999.

Latest comments (1)

Collapse
 
briandfoy profile image
brian d foy

The cpan command that comes with Perl can do this with the -D switch to get module details, including the latest CPAN version and local version.