Posted by brian d foy on May 30, 2010
References aren’t just for data structures, and many people overlook the benefit of references to simple scalars. With references to arrays and hashes you can keep those data structures in tact when you pass them to or return them from subroutines (Item 46: Pass references instead of copies). You don’t need to worry about scalar [...]
Posted by brian d foy on May 28, 2010
Here are some images from the Kindle version (on an iPad) of Effective Perl Programming. It doesn’t look bad considering how bad most other non-novels look on Kindle, and its readable. These are two non-consecutive pages: The paragraphs are nicely separated and it’s easier for you to see what is code and what isn’t. The [...]
Posted by brian d foy on May 23, 2010
Effective Perl Programming is now available in a Kindle edition: I bought it, not being a big fan of Kindle, and was surprised that it doesn’t look as bad as I thought it would on the Kindle app on the iPad (it looks similar on the iPhone and Kindle for Mac): There are some oddities, [...]
Posted by brian d foy on May 23, 2010
Before Perl 5.12, each only took a hash argument. In list context, it returns a two item list of a key-value pair you had not seen yet (unless you changed the hash in some way that re-ordered it): while( my( $key, $value ) = each %hash ) { … } This was quite useful for [...]
Posted by brian d foy on May 22, 2010
There’s a Chinese translation of _Effective Perl Programming_ in the works. I don’t know when it will be available: the translation will take some time, then the publisher has to put it on paper, then it has to show up in stores. I don’t have any details on where or how you can buy the [...]
Posted by brian d foy on May 21, 2010
Perl 5.12.1 is out, which is the sign that it’s time for normal users to pay attention to it: that first point release should have sanded down all the rough edges. As usual, the complete list of major changes is in the perldelta5.12.0 documentation, we’ll cover some more of the interesting features in The Effective [...]
Posted by brian d foy on May 16, 2010
We used B::Deparse in Item 7. Know which values are false and test them accordingly, but we didn’t say much about that module. The B namespace has many modules that do various nasty black magic things with the perl parse tree. We showed the example of the default behavior behind while reading from the diamond [...]
Posted by brian d foy on May 9, 2010
Just because you find a module that does something doesn’t mean that you have to use it. There are many excellent date and time modules on CPAN, including most people’s favorite, DateTime. In your heady rush for program purity and elegance, don’t think that you always have to use objects to do your work. Sometimes [...]
Posted by brian d foy on May 5, 2010
Addison-Wesley converted our chapter on “Files and Filehandles” to HTML and put it online for as a free sample chapter. I selected this chapter as the free sample because it was the most fun to write but also the most valuable to new Perl programmers. Filehandles are the way you interact with the world, and [...]
Posted by brian d foy on May 2, 2010
In Perl, a subroutine or other block structure that returns a value gives back the last evaluated expression, but if you’re not careful you might not recognize what that last evaluation actually is. It’s not necessarily the last statement in the block; it’s just the last one that you actually execute. For this Item, forget [...]