Is there a special variable or a function which gives me the number of use VERSION
(in this case 5.12.0
) when running the script?
#!/usr/bin/env perl
use warnings;
use 5.12.0;
Type perl -v on a command line to find out which version. ActiveState Perl has binary distributions of Perl for many platforms. This is the simplest way to install the latest version of Perl.
Check installed perl modules via terminal Available commands are: l - List all installed modules m <module> - Select a module q - Quit the program cmd? Then type l to list all the installed modules, you can also use command m <module> to select the module and get its information. After finish, just type q to quit.
Currently latest perl version is 5.24.
Perl 5.36. 0 is the current stable version of Perl.
I just quickly checked feature.pm
code - the version itself is not stored anywhere. Alex's answer already showed how to test particular features that results from the call.
Also note that use VERSION
can be called on several places (in modules for instance).
One hypothetical option would be to override use
and record the version number somewhere for inspection.
Edit: Some poking in the hook direction:
use version; # for version parsing
use subs 'require';
BEGIN {
sub require {
warn "use ",version->parse($_[0]);
# ... emulate original require
};
}
use 5.12.0;
This limited example reports the version specified, but for real use it would have to be much more robust.
You can, during compile time, poke about in the hints variable (${^H}
) (where dragons lurk) and look into the hints hash (%{^H}) (where dragons lurk, but in a public documented sort of way), this will let you know which specific features are enabled. I don't know how to work out if specifically a feature bundle, or all given features, were requested:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With