views:

457

answers:

7

Perl 5.11 is now released! Is there anything really exciting in this release, or is it mostly maintenance patches? (From what I've read so far, it appears to be a rollup of improvements we have already seen in prior releases.)

5.11 is the development release of what will become 5.12. The release process itself is changing to a monthly release model.


UPDATE: Perl 5.12 is now released (April 12, 2010).

+8  A: 

The odd number releases usually don't have anything too interesting, from what I remember. That said...

Not exactly a compelling, "that will hold me over until Perl6" release, but useful if you're looking for these kinds of things.

Chris Simmons
`perlmroapi` is also in 5.10.1.
hobbs
Odd numbered releases are the development releases.
Brad Gilbert
+14  A: 

One thing I liked is being able to use when as a statement modifier, like you can do with if and unless.

given ($something) {
    $abc    = 1 when /^abc/;
    $just_a = 1 when /^a/;
    $other  = 1;
}

for (@names) {
    admin($_)   when [ qw'Alice Bob' ];
    regular($_) when [ qw'Chris David Ellen' ];
}


I would like to see more consistency between filehandles and a dirhandles.

For example:

# these two lines are roughly identical
while( readline $file ){print} # DWIM
while( defined ($_ = readline $file) ){print}

while( readdir $dir ){say}
while( 0 != readdir $dir ){say} # this is way it currently works
while( defined ($_ = readdir $dir) ){say} # this is what I want
Brad Gilbert
++ postfix `when` is rad.
friedo
I have created a patch which implements the second part of this answer. It uses the lines that implement the `while(readline())` functionality, to also implement `while(readdir())` functionality.
Brad Gilbert
My patch made it into blead. It will hopefully come out in `v5.11.2`
Brad Gilbert
It **has** come out in `v5.11.2`
Brad Gilbert
+14  A: 

As somebody involved personally, the most important thing to me in this release is improved maintainability.

As you certainly know, the Perl core comes with many modules that are also available separately from the CPAN. Historically, it's been a large amount of work (stemmed by Steve Peters among others) to keep the CPAN releases in sync with core. In this release, Nicholas Clark (and others) have put in a lot of work to put these so-called dual-lived modules each in a directory of their own which closely mimics the structure of their CPAN counterpart. While that sounds like a trivial change (and from the user POV, it is), this required shuffling of many, many files, significant changes to the build process, and removal of various codepaths pertaining to whether the given file was being executed as part of core or CPAN (a good thing, naturally).

Furthermore, 5.11.0 has a tiny, tiny change that is quite important to me. If you put "use 5.11.0;" at the top of your code, it will automatically enable "strict". It's a minor detail, but it's been tough to get this in since it's sort of a policy change. We're emphasizing maintainability and encouragement of good practices. In short, making it a better language for the next hundred years (pun intended).

tsee
Oh, wow. Autostrict? it got in? That's huge.
Robert P
better: `use 5.011`
ysth
+4  A: 

I like that they are fixing smart matching. :)

I'm hoping however, that 5.12 is not going to come up with all sorts of new features, but make the ones in 5.10 work properly.

I've written about some of the new features in Perl 5.12 in The Effective Perler

brian d foy
Isn't 5.11.0 smart matching the same as 5.10.1?
oylenshpeegul
oylenshpeegul: Should be.
tsee
+5  A: 

I like implicit strictures. I wonder why they didn't add implicit warnings too. Almost all of my programs these days start out

use 5.010;
use strict;
use warnings;

It would be nice to just say

use 5.11.0;

instead.

oylenshpeegul
Or `use Modern::Perl`?
zoul
We didn't add implicit warnings because they can cause action at a distance. This stuff was discussed at length on the mailing list (cf. the nntp.perl.org archive)
tsee
well, at least it's still only two statements.
Robert P
+4  A: 

The Yada Yada operator or ... is interesting, if not really exciting.

zoul
+5  A: 

As of Perl 5.11.1, Perl now has module versioning built in. From the perl5111delta:

Add package NAME VERSION syntax

This new syntax allows a module author to set the $VERSION of a namespace when the namespace is declared with 'package'. It eliminates the need for our $VERSION = ... and similar constructs. E.g.

 package Foo::Bar 1.23;
 # $Foo::Bar::VERSION == 1.23

There are several advantages to this:

  • $VERSION is parsed in exactly the same way as use NAME VERSION
  • $VERSION is set at compile time
  • Eliminates $VERSION = ... and eval $VERSION clutter
  • As it requires VERSION to be a numeric literal or v-string literal, it can be statically parsed by toolchain modules without eval the way MM->parse_version does for $VERSION = ...
  • Alpha versions with underscores do not need to be quoted; static parsing will preserve the underscore, but during compilation, Perl will remove underscores as it does for all numeric literals

It does not break old code with only package NAME, but code that uses package NAME VERSION will need to be restricted to perl 5.11.X or newer This is analogous to the change to open from two-args to three-args. Users requiring the latest Perl will benefit, and perhaps N years from now it will become standard practice when Perl 5.12 is targeted the way that 5.6 is today.

As an aside, these small, consistent, incremental changes continue to get my excitement up for the future of Perl.

Robert P
Yeah I always hated how class variables are handled in Perl.
Ether