switch removed from the v5.36 feature bundle

This is a chapter in Perl New Features, a book from Perl School that you can buy on LeanPub or Amazon. Your support helps me to produce more content.


We’re almost at the end of the tragic saga of given-when, a feature added in v5.10. It lost the lexical $_ in v5.24 after that feature was demoted to experimental in v5.14. Smart matching, almost the entire point of given-when, has already been demoted to experimental status. Then, v5.28 flirted with removing given-when before deciding that was too hasty. It’s been awhile, and it’s on to the next step.

The latest humiliation is that the switch feature (really given-when) is longer part of the list of the default features enabled by requiring a version of perl, as in use v5.26;.

The feature is still there if you want to use it, but you need to explicitly enable it:

use feature qw(switch);

But, don’t start using this feature now. You’ve had plenty of time to fix it and you can get most of what you need using for instead.