Contents

Perl 5.10 was a release version of the perl programming language that included a few new special features. Around the same time that Perl 5.10 was being prepared, design was moving forward rapidly in the design of the new Perl 6 language. Perl 6 was going to be very different from Perl 5, but in some ways still very much the same.

Because the two versions were being designed simultaneously and because some of the same people were involved in both design processes, the two share a few features. From the exchange, Perl 5.10 got the smart-match operator, a switch-style given-when control structure, a defined-or operator and state variables, plus a number of internal performance enhancements.

The smart match operator is like == and eq and =~ all crammed together, with a few extra features added as well. Smart match determines whether two objects match, regardless of what type of objects you throw at it.

Perl finally has a switch-like statement built into the language. Instead of using the popular switch and case keywords found in C, Perl 5.10 uses given and when.

For instance:

my$option=3;given($option){when(0){say'Option 0 is chosen!';}when(1){say'We have an option 1 here';}when(2){say'Option is 2';}}

Perl's given/when construct is much more powerful than C's switch/case construct, however. Rather than just allowing integers as the match criteria for each when clause, strings, regular expressions, and even arrays are allowed. For instance: