wackattack has asked for the wisdom of the Perl Monks concerning the following question:

I'm reading the documentation but I still don't understand how to report the version of Getopt::Std. Any sample code I could run? I'm better at reverse engineering things. THanks! http://perldoc.perl.org/Getopt/Std.html
  • Comment on Identifying version of Perl Module: Getopt::Std

Replies are listed 'Best First'.
Re: Identifying version of Perl Module: Getopt::Std
by hippo (Archbishop) on Jul 12, 2016 at 21:12 UTC

    I've found it a common requirement to detemine which version of a module is installed (and even which of a number of installed versions perl will actually use). To this end I use the following bash function (it's set in my .bashrc)

    pmv () { perl -M$1 -e "print \$$1::VERSION . qq/\n/;" }

    It's very simple then to retrieve the version number by just supplying the module name as the argument to the function:

    $ pmv Getopt::Std 1.10 $

    It ought to be easy enough to convert this to other shells for non-bash users. HTH.

Re: Identifying version of Perl Module: Getopt::Std
by haukex (Archbishop) on Jul 12, 2016 at 20:43 UTC

    Hi wackattack,

    You can do this:

    use Getopt::Std; print "$Getopt::Std::VERSION\n";

    However, looking at the version number like that is usually not necessary unless you're testing or debugging. Why do you need it? If you want to specify a minimum version required for your script, you can say something like:

    use Getopt::Std 1.07;

    Hope this helps,
    -- Hauke D

Re: Identifying version of Perl Module: Getopt::Std
by Your Mother (Archbishop) on Jul 12, 2016 at 22:32 UTC

    More on that—oneliner to get module version, Heh-heh-heh, heh-heh. I said "moron." There are a few others threads discussing this if you want to search for more.