Posted by brian d foy on March 31, 2012
Perl 5.14 added an auto-dereferencing features to the hash and array operators, and I wrote about those in Use array references with the array operators. I’ve never particularly liked that feature, but I don’t have to like everything. Additionally, Perl 5.12 expanded the job of keys and values to also work on arrays. chromatic has [...]
Posted by brian d foy on June 19, 2011
Are you tired of adding the same modifiers to all of your regular expressions? For instance, if you might always add the /u modifier to turn on Unicode semantics on all of your patterns, including qr//, m//, and s///. Instead of remembering to do that to every pattern, the re that ships with Perl 5.14 [...]
Posted by brian d foy on December 22, 2010
[This is a mid-week bonus item since it's so short] In Perl 5.13.2, you got a non-destructive version of the substitution operator (Use the /r substitution flag to work on a copy). Instead of changing it’s target, the non-destructive version returns a new string that has the substitution. Perl 5.13.7 extends the /r to work [...]
Posted by brian d foy on November 6, 2010
There’s a significant change in syntax showing up in Perl 5.14. The array operators push, pop, shift, and unshift previously only worked on named arrays or dereferenced references. Now, thanks to David Golden, they’ll work on array references. Not only that, they’ll work on references that you’ve stored in variables or that come as the [...]
Posted by brian d foy on October 28, 2010
[This is another bonus, mid-week item since it's so short and probably mostly useless as a tweak to what you already do.] Perl 5.14 changes srand to return the seed that it used to start the pseudorandom number generator that gives you numbers through rand. There are plenty of interwebs that will explain the difference [...]
Posted by brian d foy on October 25, 2010
Perl 5.14 changes how regular expression objects stringify. This might not seem like a big deal at first, but it exposes a certain sort of bug that you may have never considered. It even broke several modules on CPAN. If you previously tested for hard-coded stringifications of patterns, Perl 5.14 is probably going to break [...]
Posted by brian d foy on October 11, 2010
Perl 5.14 gives you some new ways to represent characters so you can avoid some annoying and ambiguous interpolations. Not only that, the new syntax unifies the different ordinal representations so you can specify characters using the same syntax even if you want to use different bases. This feature was added in Perl 5.13.3, in [...]
Posted by brian d foy on October 3, 2010
Perl 5.14, when it’s released, allows you to use a return value from given-when. You have to wrap it in a do (Item 25: Use do {} to create inline subroutines): use 5.013; my $value = do { given ( $ARGV[0] ) { when( /^\p{N}+\z/ ) { ‘digits’ } when( /^\p{L}+\z/ ) { ‘alphabetics’ } [...]
Posted by brian d foy on September 19, 2010
How many times has this happened to you? You want to modify each element of an array so you send it through a map (Item 20. Use foreach, map, and grep as appropriate.). However, instead of your expected output, you only to get a bunch of numbers or empty strings back? For example, in this [...]
Posted by brian d foy on August 27, 2010
The Perl 5 Porters released 5.14. By reading the perldelta51[34]* documentation, you can see what’s new in this maintenance version of Perl. David Golden, one of the Perl 5.13 release managers, put together what he’s calling the perldeltadelta, which is just the most interesting bits of the longish perl*delta files for Perl 5.13, the experimental [...]