Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 2. Idiomatic Perl > Item 23. Make work easier with smart matching

Item 23. Make work easier with smart matching

Perl 5.10 introduced the smart match operator, ~~. It looks at the operands on both sides to decide what to do. You can set up some powerful conditions with minimal typing. Complete details are in the perlsyn, but here are some examples to whet your appetite. Smart matching is mostly used with given-when (Item 24).

If you want to use smart matching, make sure you are using at least Perl 5.10.1. The original smart match behavior changed from commutative to non-commutative (meaning that the order of operands now matters). Just to be clear, this section specifies the point release of Perl for its examples:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint