Perl: how to get the number "use VERSION"

Is there a special variable or function that gives me a number use VERSION(in this case 5.12.0) when the script runs?

#!/usr/bin/env perl 
use warnings;
use 5.12.0;
+5
source share
3 answers

I just quickly checked the code feature.pm- the version itself is not stored anywhere. Alex's answer has already shown how to test specific functions that arise as a result of a call.

Also note that use VERSIONyou can call in several places (for example, in modules).

One hypothetical option is to override useand write the version number for verification.

Change: . Some pop up in the direction of the hook:

use version; # for version parsing
use subs 'require';
BEGIN {
    sub require {
        warn "use ",version->parse($_[0]);
        # ... emulate original require
    };
}

use 5.12.0;

, .

+5

, , (${^H}) ( ) (% {^ H}) ( , ), , . , , :

perl -le "use feature qw(:5.12); BEGIN{print $^H;print foreach keys %^H}"
133376
feature_unicode
feature_say
feature_state
feature_switch

perl -le "use 5.12.0; BEGIN{print $^H;print foreach keys %^H}"
134914
feature_unicode
feature_say
feature_state
feature_switch
+4

:

$]
+ patchlevel/1000 Perl. , Perl, script, . (: perl ?)

$ PERL_VERSION
$ ^ V
The version, version, and subversion of the Perl interpreter, presented as a version object.
This variable first appeared in perl 5.6.0; earlier versions of perl will see the value undefined. Before perl 5.10.0 $ ^ V was represented as a v-string.

Those will be> than what you have on the "use" line: if you need this exact line, bite the bullet and insert it into the variable, as in:

 use 5.12.0; $WANTPERL='5.12.0';
-2
source

All Articles