Perl 5.40

Perl 5.40 was released yesterday…let's try it!

cd ~/.plenv/plugins/perl-build
❯ git pull
❯ plenv install 5.40.0 -Dusethreads
...
❯ plenv global 5.40.0
❯ perl -E 'say $]'
5.040000

What's new in 5.40? One cool thing is use v5.40 imports builtin functions, which are no longer experimental. Back when Perl 5.36 was introduced, I raved about warnings and subroutine signatures being included in use 5.36, eliminating the last of the boilerplate at the top of all of my programs. Ironically, 5.36 also introduced the curiously-named builtin module, which included several utility functions that are not built in to Perl. That means to use any of them, we need to add boilerplate back in.

For example, to use trim in Perl 5.36

❯ perl -E 'say builtin::trim shift' "  Tim "
Built-in function 'builtin::trim' is experimental at -e line 1.
Tim

without that noise, we would have to say

❯ perl -Mbuiltin=trim -Mexperimental=builtin -E 'say trim shift' "  Tim "
Tim

In Perl 5.40, we just say

❯ perl -E 'say trim shift' "  Tim "
Tim

So my scripts go from starting out

#!/usr/bin/env perl

use v5.38;
use builtin qw(trim);
use experimental qw(builtin);

back to

#!/usr/bin/env perl

use v5.40;

Nice!