I have multiple versions of Perl installed.
I have specified which version to use. But to verify, I would like to output the version of Perl from the .pl script itself.
Is this possible?
Parsing the output of "perl --version
" seems syntactically wrong in Perl scripting.
Use the predefined Perl variable $]
or the more current $^V
within a perl script:
print "Perl version: $]\n";
Example output:
Perl version: 5.018002
(Perl 5.18.2)
For more special variables, please see perlvar or http://www.kichwa.com/quik_ref/spec_variables.html.
The Perl version is stored in a couple of different Perl special variables:
#!/usr/bin/perl
print "$^V\n"; # "v5.32.0"
print "$]\n"; # "5.032000"
If you're using use English
, you have additional aliases for these variables:
use English;
print "$PERL_VERSION\n"; # "v5.32.0"
print "$OLD_PERL_VERSION\n"; # "5.032000"
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