Over on LinkedIn, someone asked me “What core PERL[sic] features do you use regularly that are new since 95?” It’s hard to be sure as the perldelta files only seem to go back to 1997 (for example, when were qw(...), q(...) and qq(...) added?), but here’s a quick list off the top of my head.
- my was, of course, added in 5.0. But 5.004 added the ability to use it in control expressions – while (my $foo = <>) – and in foreach loops – foreach my $foo (@foos)
- use VERSION
- Regex extensions – (?<=RE) and similar. Oh, and qr/.../
- Data::Dumper (added in 5.005)
- Unicode support – first added in 5.6.0 and improved in every release since
- our
- Three-argument open
- Omission of intermediate arrows in data structure lookups – $foo[$x][$y] instead of $foo[$x]->[$y]
- use warnings
- Memoize
- Test::More and Test::Simple
- say
- defined-or
- use base (or, more recently, use parent)
- yada-yada operator
Have I missed anything obvious? What new Perl features do you use most?
From your list I’d say that Data::Dumper, three arg open, and defined-or are my most used. Never did take the plunge and use say instead of print mind you. Some old habits die hard.
For me: namens captures sjouwde be in thuis list als wel..
Smart matching like ‘in’ operator
For me the defined or // operator was the most useful innovation in recent Perl, followed by (infrequent but great when you need them) state variables.
1995, that means everything that was introduced in 5.000b or later. So, it will be quite a list, but there would not be a lot that I regular use that was introduced after 5.6 (there were a few things in 5.10 (say, state, //, named captures, (?|)) that I use). There’s nothing past 5.10 that I use.
As for five years between 5.000b and 5.6.0, it would be autovivifying filehandles (lexical filehandles were possible in 5.000, hence 1994), our, my on for loops, while () with implicit defined, regexp features that have been experimental for more than a decade, lexical warnings, use VERSION, /x on regular expressions, 3-arg open. Probably a handful that I either don’t realize, or don’t realize they weren’t in 5.000 yet.
But the majority of my coderuns with minimal changes on 5.000.
s///r in v5.14
Sorry about previous non-sense: “For me: Named captures should be in this list as well” (Kids turned iPhone to Dutch…)