Use perl 5.10: Given / when

The feature I’ll talk about here is the given/when construct, which was added in perl 5.10. It works like switch/case in other programming languages, but is much more powerful. The matching is based on smart matching, which is another feature added in 5.10; I will start with a simple example to give you an idea of the syntax that is used. use 5.010; my $x = <>; chomp $x; given ($x) { when ([0....

March 8, 2010

Use Perl 5.10: Named capture buffers

In the latest version of Perl 5 the regex engine also got a big upgrade. There are many changes that made it faster and more correct for certain regexes. This time I will explain the new features called Named capture buffers. Named capture buffers are similar to the numbered capture buffers, like $1 and $2. The named versions of these work the same except that you can give them a name like name or value....

November 8, 2009