如何在没有许可证和构建信息的情况下获取Perl版本字符串?

前端之家收集整理的这篇文章主要介绍了如何在没有许可证和构建信息的情况下获取Perl版本字符串?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
perl –version打印所有这些:

This is perl 5,version 26,subversion 1 (v5.26.1) built for darwin-thread-multi-2level

Copyright 1987-2017,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.

我想要的是这个:

5.26.1

是否有任何开箱即用的方法,或者我是否需要编写自己的正则表达式从详细输出提取它?

解决方法

变量 $^V具有该信息.你可以直接从Perl里面打印出来:

#!/usr/bin/perl

use strict;
use warnings;

print $^V;

或者你可以用bash获得它:

perl -e 'print $^V'

两个版本都在我的系统上打印“v5.22.1”.

猜你在找的Perl相关文章