Posted by brian d foy on October 31, 2010
Nowadays, perl development happens at a fast clip. Every month there’s a new development release that gives you a preview of what’s going to show up in the next stable version. This not only gives the perl developers a chance to test the new perl in the wild, but also for you to try new [...]
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 17, 2010
Although Perl makes it very easy to create, extend, or otherwise modify arrays, that doesn’t mean that a Perl array is the best way to store and search data. Not only do large arrays use up a lot of extra memory for each element (for an in-depth discussion, see the “Tie” chapter in Mastering Perl), [...]
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 July 25, 2010
Perl 5.12 deprecates several features, for various reasons. Some of the features were always stupid, some need to make way for future development, and some are just too ornery to maintain. All of these are listed in the perldelta5120 documentation. The new thing, however, is that Perl 5.12 will warn you about these even if [...]
Posted by brian d foy on March 7, 2010
In Item 110: Compile and install your own perls, we showed you how to compile and install several versions of perl so that they don’t conflict with each other and you can use them simultaneously. Since they don’t install their programs, they are left in their $prefix/bin directories. With several perls, each of which has [...]
Posted by brian d foy on February 27, 2010
Perl’s object system is fuzzy. Methods are really just subroutines and classes are just packages, which means that any subroutine in a package is also a method in that class. Your class might have subroutines that you’ve never even noticed, so you end up with methods that you didn’t want in your interface. There are [...]
Posted by brian d foy on February 7, 2010
In Item 110: Compile and install your own perls, you saw how to install multiple versions of perl and to maintain each of the installations separately. Doing something with one version of Perl doesn’t affect any of the other versions. You can take that a step further. Within each installation, you can use a source [...]