Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Wouldn’t it be great if computers could just figure out what you
wanted and do that? Perl already does its best to use numbers when you
want numbers, strings when you want strings, single values where you mean
a single value, and lists when you mean multiple items. With Perl 5.10’s
smart match operator and given-when
control structure, it gets even better.
Smart matching showed up in Perl 5.10.0, but in a broken form. That’s not a big deal because most of the problems disappeared in Perl 5.10.1. (That means that you may need an updated version for this chapter.) Don’t even consider using smart matching in Perl 5.10.0. It will just cause problems later. As such, we’re going to be much more specific about the Perl version in this chapter by specifying the point release version to remind you to use an appropriate version: