Category Archives: Second Edition - Page 2

New To “Jury Rigging and Modifying Modules”

Chapter 10 is another easy chapter to update. The language hasn’t changed enough to affect how we deal with Perl’s object system (although Perl might not always be that stable). I did bring in a few paragraphs about Git, pull requests, and Git::CPAN::Patch. Check out this chapter in O’Reilly Atlas.

ReturnValue on PrePAN

As part of the “Error Handling and Reporting” chapter, I’ve developing my use of normal return values to indicate failure. Instead of tricky value checking, I can use the object type to decide what happened and then look in the object to get the value. That way, success and error values can use the same code path. I’ve created ReturnValue on Github.

Before uploading to CPAN, however, I’m trying PrePAN for the first time. This allows me to show off ReturnValue to the Perl community without claiming the namespace. I don’t deal with PAUSE at all. If I decide to abandon it, it’s no big deal. Comment on ReturnValue at PrePAN.

You can also read the draft chapter on O’Reilly Atlas.

New to “Error Handling”

There’s much to update in Chapter 12, “Error Handling”. I thought this would be an easy chapter.

Since v5.10, Fatal is different and now called autodie. I mostly had to change the module names. The biggest change was removing the non-void non-handling of builtins that Fatal could do. If Fatal saw I checked the return value of a builtin myself, it doesn’t throw the exception for me. I excised that paragraph.

In v5.14 the behavior of [email protected] changes quite a bit. An eval inside a destructor won’t mess up [email protected] as the scope is cleaning up.

I’m covering Try::Tiny and TryCatch. I’m still working on those sections.

Do you have anything else I should include or update? See what I have so far by reading it through Atlas.

New to “Logging”

I’ve expanded the Logging chapter to discuss more of the Log4perl features, including the Nested diagnostic context and the Mapped Diagnostic Context, both of which allow me to keep track of information that I can interpolate into log message.

I expanded the discussion of categories a bit more, but not that much. I think it’s a pretty simple feature.

See if you like it by reading it through Atlas.

New to “Cleaning Up Perl”

There’s not much that I needed to update in the chapter devoted to Perl style. The Perl::Tidy stuff is the same and I updated the Perl::Critic with a new program to analyze.

When I originally wrote this chapter, use.Perl was still going and I used my journal reading program as the violation program. Since that site is no longer active, I switched to my retweeter roulette program that I use to select winners from my twitter giveaways.

There are some errors there, but my style has evolved in the seven years since then so I had to work a little harder to get violations.

I also added a bit more on turning off policies, especially for single lines. I left it out last time as a way to discourage it through ignorance, but I’ve changed my mind about that. Using the ## no critic trick is so annoying that it’s easier to comply.

Have I left anything out that you like to do? You can read Chapter 7 through the O’Reilly Atlas pre-publication review program.

New to “Working with Pod”

There’s not much to update in the Pod chapter; the Pod specification hasn’t changed that much since I first wrote the book.

I did add a short section on the =encoding header and using non-ASCII characters directly instead of using interior sequences.

I updated the Pod::Perldoc::ToToc example, which had a couple of weird errors from a short period when I liked using shift to process argument lists. I’d make mistakes that strict would catch:

sub foo {
    my( $self ) = shift;

    do_something( $second_argument );
    }

However, I was taking strict lines out to save a little space on the page. Going back and forth a few times introduced some newbie errors.

With v5.12 automatically turning on strict when you require that version, I won’t have that extra line problem.

New to “Advanced Regular Expressions”

You can read the draft of Chapter 2 in O’Reilly Atlas.



There’s much that I can change in this chapter:

  • Set operations in regular expressions
  • The \K
  • The performance penalty of $& and that Devel::NYTProf finding the problem areas.

New in “Secure Programming Techniques”

This chapter contains most of the original text, although with a few tweaks. There are two big additions which I did not cover in the first edition of this book.

I added a section on security with the DBI module and SQL injection. I don’t really think it belongs in this book any more than any other sort of problem with a CPAN module, but enough people complained that I relented.

And, I added a brief introduction to the Safe module. This is a rarely used security feature that you might find useful if you have to use string eval.

I’ve added some of the sample programs to the downloads page.

You can read the draft chapter now.

New in “Working with Bits”

You can read the draft of Chapter 16 in O’Reilly Atlas.


Bits and bit vectors in Perl haven’t changed since the first edition, so there’s not much to update in this chapter. I thought that Abigail’s prime number regex might deserve some space, but it turns out that it didn’t.

I also thought that the octal prefix 0o had made it in since it’s proposal back in the v5.15 days. It had some interesting parsing problems, and eventually the proposal was dropped.

When I last worked on this book, I was running a 32-bit perl with v5.8. Now I have a 64-bit v5.18. The output of some of the Devel::Peek examples changed a little, so I updated those.

I added an example of using a bit vector to cache the positions of prime numbers. I can create a big string where each bit represents one number. When it’s time to check if a number is prime, I simply check the right bit.

Finally, at the end of the chapter, I updated the URLs for “Further Reading”. In eight years the URLs have moved around a bit.

Mastering Perl 2e draft in O’Reilly Atlas

O’Reilly Media has been moving to a new publishing platform that’s making things much easier for everyone I think. Mastering Perl, Second Edition is my first experience with this.

Besides moving from Subversion to Git (yay!), my intermediate draft sources are available in real time through O’Reilly Atlas. You can read what I’ve got so far for free, sponsored by OSCON. Mostly what you’ll see there right now is the first edition since I’ve been slow to move over what I was doing in the old process to the new process.

This is your chance to influence what happens in the second edition. The structure and topics mostly stay the same, but everything will be updated.