Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the Perl version string without license and build information?

Tags:

perl

perl --version prints all this:

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.

What I want is this:

5.26.1

Is there any out-of-the-box way to get that, or do I need to write my own regular expression to extract it from the verbose output?

like image 511
David Moles Avatar asked Mar 26 '18 21:03

David Moles


1 Answers

The variable $^V has that information. You can print it directly from inside Perl:

#!/usr/bin/perl

use strict;
use warnings;

print $^V;

or you can get it in bash:

perl -e 'print $^V'

Both versions print "v5.22.1" on my system.

like image 88
pconley Avatar answered Sep 17 '22 04:09

pconley