Perl v5.36 is out


Perl v5.36 is out and is very interesting.

In the last years I’ve become accostumed to use v5.24 for several reasons:

  • it’s the first to provide the experimental::signatures thing that I like to use in a shape that I hope it’s become stable;
  • it’s reasonably widespread (that, or something appeared later), so I can use it and not worry;
  • strictures are enabled by default.

I have to say that Perl v5.36 is tickling me a lot. There’s a couple of things that might seem like minor stuff to others, but I think they can be incredibly useful. Although yes, probably not that big deal!

From my first read of perldelta, this got my attention:

my @listy = qw<
    foo   bar   baz
    Foo   Bar   Baz
    fooey barry bazzy
for my ($foo, $bar, $baz) (@listy) { ... }

This goes very well with the new indexed stuff too:

use builtin 'indexed';
my @listy = qw< foo bar baz >; 
for my ($index, $val) (indexed @listy) { ... }
my $messy = '   this needs some\ntrimming  ';
my $tidy  = builtin::trim($messy);

This is mainly a matter of readability, I know I could also do:

my $messy = '   this needs some\ntrimming  ';
my $tidy  = $messy =~ s{\A\s+|\s+\z}{}rmxs;

Readability is important though!

  • defer blocks: this lets us define guards without resorting to tricks, which is amazing:
use feature 'defer';
sub whatever {
    say "This happens first";
    defer { say "This happens last"; }
    say "And this happens inbetween";
    defer { say "Nothing, this is not printed" }



This happens first
And this happens inbetween
This happens last

So… I’ll probably give it a try!

Stay safe folks!

Comments? Octodon, , GitHub, Reddit, or drop me a line!