List comprehensions in Perl (almost)

[I wrote this about two years ago and waited for some inspiration that would make it a little better. That inspiration never showed up. In the new year I’m cleaning out all the draft articles though.]

I went off to see what list comprehensions are all about. Lately I’ve run across several bits of Python I’ve wanted to use. I don’t mind Python so much but I’m certainly rusty; I spend some time on StackOverflow where I run into the term “list comprehension” quite a bit. They sure like whatever that is so I went off to investigate. Someone might want one of those in Perl, hence the click-baity title of this post (a better one might be “12 Ways to…”). » Read more…

Trying to divide the smallest hexadecimal number

You can run into problems relying on the averages of floating point numbers. This is something I think about often after reading Sinan Ünür’s How you average numbers matters. I thought about it again when I read Honza Brabec’s Mean of two floating point numbers can be dangerous. Despite the hyperbole of “can be dangerous” (see “Considered Harmful” Essays Considered Harmful), it certainly can do something that you don’t intend. » Read more…

Using Inline::C to look at a number’s double representation

Since Perl v5.22 added hexadecimal floating-point numbers, I investigated how floating point numbers are actually represented. These are specified in IEEE 754 and are something you’ve probably taken for granted. I can use Inline::C to play with these. » Read more…

Pre-compiled patterns retain their settings if they are interpolated

The qr// operator precompiles a regular expression and returns a reference to that compiled pattern. You can use that reference with the binding operator to perform a match, interpolate the reference into the match or substitution operators, or combine the reference with other references or literal patterns to make a larger pattern. We cover this in Chapter 9, “Regular Expression References”, but don’t emphasize what happens with regex flags when you combine patterns. » Read more…

Second printing available

Intermediate Perl 2nd edition’s second printing is now available. This contains fixes for almost all of the reported errata, but it otherwise the same content.

If you’ve bought your ebook through O’Reilly, you should have it available in your O’Reilly account. Look at your O’Reilly products list. I have the Alpaca under mine and I can immediately download the format I want or send them to Dropbox.

The Alpaca gets a second printing

Most tech books have trouble selling even a couple thousand copies, which makes it tough for a publisher to figure out how many to print at first. Print too many and they’ll just sit there, or worse. The publishing industry is a bitch because the book shops can returned unsold inventory and get money back. On every royalty statement, I have a “reserve withheld” and a “reserve returned”. The publisher reserves some of my royalty in case the book stores return books. After a certain period, they return that. But, they then withhold more. That’s just the way it is. » Read more…

Clarifying local::lib and cpan in Chapter 2

local::lib is highlighted in Intermediate Perl when I go through the CPAN tools in Chapter 2. Each of the tools has a slightly different set of features and I try to steal the good one. I added a local::lib to cpan so you can add the local::lib defaults for a one-shot installation process. This steals a feature from cpanm which has a --local-lib option: » Read more…

Answers for O’Reilly PR

The O’Reilly public relations people asked me to answer some questions about the new Intermediate Perl so they can prepare materials for reviewers and the press. As a reader of this website, however, you get the answers before they do, and you get my full answers, which might show up as edited excerpts in O’Reilly’s materials. » Read more…

Get 50% off Perl ebooks, including Intermediate Perl

You can buy Intermediate Perl now, directly from O’Reilly in ebook form. For the next week, you can buy it for 50% off using discount code WKPER5.

50% off

Every ebook from O’Reilly is DRM free and come in PDF, ePub, and Mobi formats. If you’ve authorized O’Reilly’s Dropbox app, once you’ll purchase the books they’ll sync to your Dropbox account (in ~/Dropbox/Apps/O’Reilly Media). You can read them on any device anywhere you are.

The print version is still making its way out of the printers and to distributors, but we expect it to show up in the next three weeks.

Intermediate Perl is available for pre-order

You can now buy Intermediate Perl. I’ve just submitted the final changes and the final publishing bits should finish this week, sending the result to the printers very soon. The book should ship before the end of August.


If I haven’t listed your favorite bookseller, send a link.