Posted by brian d foy on December 18, 2011
[ This is the 100th Item we've shared with you in the two years this blog has been around. We deserve a holiday and we're taking it, so read us next year! Happy Holidays.] Perl 5.10 added rudimentary grammar support in its regular expressions. You could define many subpatterns directly in your pattern, use them [...]
Posted by brian d foy on April 17, 2011
Perl 5.10 introduced a flexible method resolution order mechanism. Instead of Perl’s default order (see Understand Perl’s default inheritance model), you can try something less stupid by using the mro pragma to specify which order perl. So far, there are only two resolution orders: dfs, which is Perl’s default depth-first search, and c3, a new [...]
Posted by brian d foy on March 27, 2011
Byte-order modifiers are one of the Perl 5.10 features farther along in perl5100delta, after the really big features. To any pack format, you can append a < or a > to specify that the format is little-endian or big-endian, respectively. This allows you to handle endianness in the formats that don’t have specify versions for [...]
Posted by brian d foy on December 26, 2010
The smart match operator (Item 23. Make work easier with smart matching) reduces many common comparisons to a few keystrokes, keeping with Perl’s goal of making the common things easy. You can use the smart match operator to make even less common tasks, such as matching many regular expressions at the same time, just as [...]
Posted by brian d foy on October 13, 2010
[This is a mid-week bonus Item since it's so short] Prior to Perl 5.10, you had to be a bit careful checking a Perl variable before you set a default value. An uninitialized value and a defined but false value both acted the same in the logical || short-circuit operator. The Perl idiom to set [...]
Posted by brian d foy on September 5, 2010
Perl’s regular expressions have a simple rule for capturing groups. It counts the order of left parentheses to assign capture variables. Not all capture groups must actually match parts of the string, and Perl doesn’t care if they do. Perl assigns capture groups inside an alternation consecutively, even though it knows that only one branch [...]
Posted by brian d foy on July 4, 2010
To specify that you wanted to use at least a particular version of Perl, you specified that version with the use built-in: use VERSION; We covered this in Item 83: Limit your distributions to the right platforms, and we mentioned that it might invoke side effects. We didn’t get into the details in that Item [...]
Posted by brian d foy on December 31, 2009
Perl 5.10 introduced many new features that had built up over the years. Some of these we covered in the book, but we’ll cover some of those that we neglected. It might take us some time to get around to them all, but we’ll eventually make it. If you want to read about some sooner [...]