Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Which version is this module?

by bart (Canon)
on Jan 14, 2004 at 16:19 UTC ( #321286=sourcecode: print w/ replies, xml ) Need Help??

Category: Utility scripts
Author/Contact Info bart
Description: Sometimes you wonder what version of a module you have, and it's easy enough to come up with a oneliner to do it, loading the module and printing out the value in its $VERSION package variable. However, life can be somewhat easier still, and so I wrapped this oneliner into a .bat batch file (for Windows/DOS). So copy this one line, paste it into a new text file "version.bat" (avoid adding newlines if you can), and save somewhere in your path — I saved it in my perl/bin directory, next to the perl executable.

Use it from the "DOS" shell as:

version CGI
version DBD::mysql
@perl -M%1 -le "print $%1::VERSION"

Comment on Which version is this module?
Re: Which version is this module?
by robobunny (Friar) on Jan 15, 2004 at 14:00 UTC
    And with minor modifications, this is also a valid shell script, for those on UNIX:
    perl -M$1 -le "print \$$1::VERSION"
      robobunny wrote:
      And with minor modifications, this is also a valid shell script, for those on UNIX:

      Weeellllll ... {G} ... with MAJOR modifications and wrapping it in a shell function wrapper, so it is available at every login w/o regard to PATH location, this idea becomes:

      # (ba)sh function wrapper for Perl code. "perltest" is admittedly NOT + a good name ;-) perltest () { perl -e' my$modn = my$mod = "'$1'"; $mod =~s@::@/@g; $mod.=q[.pm]; die ("module $modn not installed.\n",$@) if ! eval {require qq[$mod];}; my $modv = defined ${$modn.q[::VERSION]} ? ${$modn.q[::VERSION]} : q{[version undefined]}; my$numtyp= (2 > $modv =~tr/.//) ? "%s" : "% 6d"; printf " %-*s $numtyp in %s\n", length($modn) > 30 ? 5+length($modn) : 15+length($modn), $modn, $modv, $INC{$mod}; '; return 0 }

      I use this so often, sometimes several times a day, that the extra elaboration has proven well-worth it to me.

          Soren A / somian / perlspinr / Intrepid
      P.S. Don't forget: I am expecting all the people the people who say I am posting to Perlmonks for the XP to automatically downvote this posting w/o explanation, thanks.

      Now, 2004: The 3 least meaningful terms in online jargon are:
        troll   flame   rant
      These used to mean something; but then they were highjacked by the kind of
      inferior intellects who, when faced with a more erudite opponent employing
      superior arguments (or simply hanging in there with a disagreeable
      contention), abuse these terms as merely another form of name-calling. ;-)
        I like
        perl -MCPAN -e 'CPAN::Shell -> m (shift)' MODULE
        which not only gives the installed version number, but also the version number of the newests version on CPAN.


Back to Code Catacombs

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://321286]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-09-20 15:48 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (160 votes), past polls