Posted by brian d foy on July 1, 2012
Pod::Simple 3.21 changed its behavior when it encountered a non-ASCII character in Pod without an encoding. Instead of handling it quietly, it now gives a warning. That’s not so bad, but Test::Pod uses Pod::Simple, and whenever it sees a warning, pod_ok fails, as it did in my Mac::Errors module: # Failed test ‘POD test for [...]
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 December 11, 2011
Perl’s basic data type is the scalar, which takes its name from the mathematical term for “single item”. However, the scalar is really two things. You probably know that a scalar can be either a number or a string, or a number that looks the same as its string, or a string that can be [...]
Posted by brian d foy on December 4, 2011
If you project depends on a interaction with a web server, especially a remote one, you have some challenges with testing that portion. Even if you can get it working for you, when you distribute your code, someone else might not be able to reach your server for testing. Instead of relying on an external [...]
Posted by brian d foy on November 27, 2011
Perl’s split has some special cases and some perhaps surprising cases. The empty pattern, zero width match, the special argument ‘ ‘, and the /^/ act differently than you might expect from the general rule. The empty pattern, // The empty pattern is a special case that’s designed to give you a list of characters. [...]
Posted by brian d foy on November 20, 2011
You can write your own mini (or micro) debuggers to watch your program run. You might want to do this when the other Perl debuggers are too heavyweight (or even too interactive) for your immediate problem. The Devel::Trace module is a simple debugging tool that lets you watch the flow of control as your program [...]
Posted by brian d foy on November 13, 2011
You can use several different Perl modules to inspect data structures. Many of these modules, however, are really two tools in one. Besides showing a data structure as a string, they also serialize the data as Perl code so you can reconstruct the data structure. That second job often makes things hard for you. If [...]
Posted by brian d foy on October 30, 2011
To create grep- or map-like syntax, you need to use Perl’s prototypes, despite whatever we told you in Understand why you probably don’t need prototypes. Perl needs the special hints that prototypes to parse a block as an argument to a subroutine. First, remember the forms of grep. There’s a single expression version and a [...]
Posted by brian d foy on October 23, 2011
Profile before you decide where to optimize—you might be surprised where you’re losing all of your performance. We won’t go into all the details of profiling in this Item, but you can read about those in Mastering Perl. In short, profilers count something then report the results. They can track any of the things that [...]
Posted by brian d foy on October 16, 2011
There are some regular expression tricks that can help you deal with balanced delimiters in a string. The split command takes a pattern, removes the parts of a string that match that pattern, and give you a list of the parts of the string between those separators. Said another way, split works when the parts [...]