开发者

How do I get the Perl's DateTime::Format::DateManip version number from the command line?

I'm using this from the command line:

perl -MDateTime::Format::DateManip -le 'print $Some::Module::VERSION'

but only return a blank 开发者_StackOverflowline, any thoughts?


It is pseudo-code, Some isn't set so it is just printing out undef with the -l flag, like perl -le'print undef;

For evidence turn on warnings with -w

$ perl -MDateTime::Format::DateManip -wle 'print $Some::Module::VERSION'
Use of uninitialized value $Some::Module::VERSION in print at -e line 1.

Substitute Some::Module with the module you want the version of.

Also, just for fun ;)

Perl Shorthands for testing version numbers

These are quick ways to get version numbers by utilizing the use <module> <version> syntax and perl's vocal rejection of versions that aren't new enough.

These are all equivalent of creating a perl script with use DateTime 9999;

$ perl -MDateTime\ 9999
DateTime version 9999 required--this is only version 0.51.
BEGIN failed--compilation aborted.

However, this fashion isn't cross-platform, because you're simply telling bash to escape a space. This doesn't work in windows cmd, for that you'll have to

$ perl -M"DateTime 9999"
DateTime version 9999 required--this is only version 0.51.
BEGIN failed--compilation aborted.

Here, you just put it in quotes - that tells cmd to send it all as an argument to perl and it gets the same job done.


If you find yourself doing this frequently, you can download and install pmvers from CPAN. The script will save you from typing a potentially lengthy module name twice:

pmvers DateTime::Format::DateManip
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜