Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What version does the Perl interpreter use by default?

Tags:

perl

I wrote a simple script using given/when to try out this feature, but I kept getting compilation errors. Eventually, I included use 5.010_001; at the top of the script, thinking maybe my Perl version is too old to use given/when. It worked.

I then printed my Perl version with $] and used it instead: use 5.018_002;, which also worked. Why isn't Perl using the features from the latest installed version by default?

like image 616
Novice Avatar asked Nov 01 '25 17:11

Novice


1 Answers

The statement

use VERSION;

does an implicit

no feature ':all';
use feature ':VERSION';

So:

Why isn't Perl using the features from the latest version installed by default?

According to perldoc feature:

It is usually impossible to add new syntax to Perl without breaking some existing programs. This pragma provides a way to minimize that risk. New syntactic constructs, or new semantic meanings to older constructs, can be enabled by use feature 'foo', and will be parsed only when the appropriate feature pragma is in scope.

like image 178
ThisSuitIsBlackNot Avatar answered Nov 04 '25 14:11

ThisSuitIsBlackNot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!