Deprecation warnings now tell you when the features will disappear

Perl v5.28 will have better deprecation warnings. Most of this I picked up from the lightning talk that Abigail gave at The Perl Conference.

Perl 5, released in 1994, deprecated many things that it never removed. It’s over 20 years later and those things are still there. Even though they are deprecated they had no schedule for actual removal. The Perl 5 Porters are now paying attention to these things but following perlpolicy by removing them after two (or more) stable releases. Some things have been scheduled for particular releases as noted in perldeprecation. Similarly, you might be interested in perlexperiment

Consider the misfeature of an opening heredoc with no label:

use strict;
use warnings;

my $string = <<;
	This is the heredoc

print $string;

You get the warning:

$ perl5.8.9 bare-heredoc.pl
Use of bare << to mean <<"" is deprecated
	This is the heredoc

In the just released v5.26.0 the warning got a bit more interesting. The deprecations now have a schedule and the warnings note that:

$ perl5.26.0 heredoc.pl
Use of bare << to mean <<"" is deprecated. Its use will be fatal in Perl 5.28 at heredoc.pl line 5.
	This is the heredoc

In v5.28 you’ll need to use the quote marks:

use strict;
use warnings;

my $string = <<'';
	This is the heredoc

print $string;

v5.27 already makes this fatal:

$ perl5.27.2 -c heredoc.pl
Use of bare << to mean <<"" is forbidden

It might look odd to have no visible closer for the heredoc. But, here’s a curious use in the new indented heredoc. With a zero-length delimiter and an indented closing line you have to be sure the whitespace stays in the file. I’ve used ⤷ to represent a tab:

use strict;
use warnings;

my $string = <<~'';
⤷   This is the heredoc
⤷

print $string;

I’ve set my editor to automatically remove trailing whitespace. That will change the output of this program. But I don’t plan on using a zero-length delimiter for my heredocs. I only know I can because Abigail gave a lightning talk about it.