Perl 5.10 Is Out
[Moozik: The Frozen Autumn - Faceless Names]
Perl 5.10 is now available and has some rather nice new features. Along with a faster interpreter with a smaller memory footprint, Perl now has a switch statement, a defined-or operator and a new smart match operator.
The defined-or operator // is handy as you no longer have to write
defined $a ? $a : $b
and can instead just write
$a // $b
The new smart match operator ~~ is a powerful new feature that just does the right thing depending on what its arguments are. Smart matching in detail has all the new implied matches. I love that you can use ~~ in such a wide variety of matching decisions.
Does my array contain the number 5?
if (@array ~~ 5) ...
Does my hash contain the word Simon?
if (%hash ~~ 'simon') ...
Does my variable contain the string bugger?
if ($variable ~~ 'bugger') ...
Are these two coderefs identical?
my $a = sub { print "howdy\n" };
my $b = sub { print "howdy\n" };
if ($a ~~ $b) ...
Leave a comment