現在利用できるPerlのバージョンを確認する際, 通常はperl -v
の出力から確認するのではないでしょうか.
$ perl -v This is perl 5, version 20, subversion 1 (v5.20.1) built for darwin-2level Copyright 1987-2014, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
...が, これより短い出力で取得する方法があります.
perl --help
でヘルプを見ると,
-v print version, patchlevel and license -V[:variable] print configuration summary (or a single Config.pm variable) -w enable many useful warnings
このような記述があり, これを利用してperl -V:version
を実行すると,
$ perl -V:version version='5.20.1';
このような形でPerlのバージョンを取得することができます. 多分これが一番短いと思います.
...ってQiita:Teamに書いたら, 社員の人に
$ perl -e 'print $^V' v5.20.1
の方が出力が短い, というツッコミを受けたのがオチとなります. 様式美ですね, 本当にありがとうございました.