What version of Perl introduced try / catch?

765 Views Asked by At

I know Perl recently got try / catch. What version of Perl though shipped with it?

2

There are 2 best solutions below

0
Evan Carroll On BEST ANSWER

Perl 5.36 added native support for finally.

1
brian d foy On

The mostly ignored perlexperiment page lists the features as they are added and (sometimes) later graduated out of the experimental category. You can also see when features were removed.

If you use the version at perldoc.perl.org, you are probably always reading the latest version of the stable docs (maybe off a few days right after a release), so you don't need to rely on your local docs. However, if it's not in your local docs, your Perl doesn't have it. :)

Similarly, the feature.pm docs shows the name of each feature, the name for its experimental warning when appropriate, and which version bundles each feature shows up in. That is, when you include use v5.x, which features are automatically included.

The experimental pragma (starting in v5.18) is useful in the same way, and perhaps a better summary of everything. Instead of these two lines:

use feature qw(try);
no warnings qw(experimental::try);

you have this one line:

use experimental qw(try);

That's even handier when you are turning off several feature warnings since you don't type out experimental:: before each of them:

use experimental qw(signatures try);