Perl 5.10 Is Out

| Comments (0)

[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

About this Entry

This page contains a single entry by kev published on December 21, 2007 7:53 AM.

Read It Later was the previous entry in this blog.

You See, We Don't Really Get Snow In Phoenix is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.