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?
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.
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