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 April 10, 2011
There’s a popular internet meme that says a July will only ever have five complete weekends, a Friday-Saturday-Sunday triplet, only every 823 years. To programmers, that might seem just absurd, but a lot of people believe it without thinking about it: that’s how it becomes the popular internet meme. It’s almost trivial to disprove the [...]
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 March 20, 2011
Perl’s default inheritance mechanism is a bit weird, and it’s not something that any language designer would want to repeat. However, it is what it is and by knowing its quirks you should have any easier time tracking down inheritance problems. Before you go further in this Item, though, you have to sit through this [...]
Posted by brian d foy on February 6, 2011
Data::Dumper, a module that comes in the Standard Library, is one of the great tools knows to Perlers. You give it a big data structure and it pretty prints it for you. If you are one of those people who still believe that the best debugger in the world is print and need to get [...]
Posted by brian d foy on December 5, 2010
How often have you wished that one of Perl’s modules did things slightly differently? That module mostly works for you except for some hard-coded decisions in string formats, pack specifications, or other minor point that you wish that you could configure. Or, maybe you’ve been the one to write that module. When you have to [...]
Posted by brian d foy on September 27, 2010
This Item was suggested by Shawn Corey as part of our Free eBook give-away. He’s our September winner! Perl is mostly a platform-agnostic and portable language, but there are a few corners where you notice that Perl isn’t in control of everything. In Item 14: Handle big numbers with bignum, you saw that Perl’s normally [...]
Posted by brian d foy on August 22, 2010
Perl’s format feature allows you to easily create line-oriented text reports with pagination, and if that’s what you want, Perl is for you. This item is just an introduction. You can find the full details in perlform, and in future items. You may have never heard of formats, but, believe it or not, they were [...]
Posted by Josh McAdams on August 8, 2010
My choice of algorithms and data organization can lead to orders of magnitude of performance differences between functionally equivalent implementations of my programs. Choosing the right way to do something can save me orders of magnitude in processing. I wrote some code to loop over lines in a file and modify a couple of elements [...]
Posted by brian d foy on August 1, 2010
Perl 5.12 can turn on strict for you automatically, stealing a feature from Modern::Perl that takes away one line of boilerplate in your Perl programs and modules. We talk about strict in Item 3: Enable strictures to promote better coding. Similar to what we show in Item 2: Enable new Perl features when you need [...]