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....