Josh and I got hard copies of the Effective Perl Programming, Second Edition last week, and Amazon says they are in stock.
Effective Perl Programming’s table of contents
Here is the final table of contents for Effective Perl Programming, 2nd Edition. The “Item” references in our blog entries refer to the items in the book. We also have a map from the Item numbers in the first edition to those in the second, but we’ll have to do a little work to make those look nice for the blog. Continue reading “Effective Perl Programming’s table of contents”
Interact with the system when Perl isn’t enough
Usually, you want to do as much of your work inside your Perl program as you can. CPAN has a wealth of modules that accomplish many tasks, including those that you normally do very easily from the command line. In the cases where you can’t find a module, you might not be able to improve on the command-line siutation for complicated tasks. Perl is, after all, a glue language, so you don’t always have to do everything in Perl. When you decide to use an external program, there are many Perl features waiting to help, although you have to choose the right one for the job. Continue reading “Interact with the system when Perl isn’t enough”
InformIT has an Effective Perl Item: Process HTML with a Perl Module
As part of the promotional package for Effective Perl Programming, I wrote Process HTML with a Perl Module for InformIT. It’s just like the Items that you see here, but on another site.
Use /gc and \G in matches to separate alternations in separate, smaller patterns
Perl keeps track of the last position in a string where it had a successful global match (using the /g
flag). You can access this position with the pos
operator. With Perl 5.10, you can use the /p
switch to get the per-match variable ${^MATCH}
instead of the performance-dampening $&
: Continue reading “Use /gc and \G in matches to separate alternations in separate, smaller patterns”
Know the difference between regex and match operator flags
The match and substitution operators, as well as regex quoting with qr//
, use flags to signal certain behavior of the match or interpretation of the pattern. The flags that change the interpretation of the pattern are listed in the documentation for qr//
in perlop (and maybe in other places in earlier versions of the documentation): Continue reading “Know the difference between regex and match operator flags”
Install scripts from distributions
Perl’s distribution system is quite powerful and supported by a variety of tools that can make life easier for you. Most people tend to think that “distributions” are synonymous with modules, but that’s only one of the uses for distributions. Continue reading “Install scripts from distributions”
Make deep copies
When you want to make a completely disconnected copy of a hash or an array, it’s not enough to merely assign it to a new variable name, at least in the general case: Continue reading “Make deep copies”
Process XML data with XML::Twig
People often reach for regular expressions to extract and rearrange information in XML documents. Those usually only work for the limited test cases people specifically target, but are really little time-bombs waiting to go off when the data or the format changes even slightly. The bomb often explodes after the original programmer has disappeared. Continue reading “Process XML data with XML::Twig”
Make links to per-version tools
In Item 110: Compile and install your own perl
s, 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 perl
s, each of which has their own modules directories, using tools such as cpan
and perldoc
can get confusing. Which version of those tools are you using and which perl
are they trying to use? Continue reading “Make links to per-version tools”