Category Archives: Changes - Page 2

New to “Dynamic Subroutines”

“Dynamic Subroutines” is one of my favorite chapters in Mastering Perl, although it’s not a long one. When Allison Randal and I were first planning the book, we didn’t want to cover anything that was already done well in another book. Since Mark Jason Dominus had already exhausted the subject in Higher-Order Perl, I didn’t belabor the point.

Not much has changed in Perl in this regard, although Perl v5.16 added the __SUB__ token so we can reference the current subroutine even if we don’t know its name.

Check out this chapter in O’Reilly Atlas.

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.

New to “Configuration”

I didn’t have to make many changes to Chapter 11: Configuration. This is mostly a stable part of the Perl ecosystem. I updated a few minor things.

Readonly is out, Const::Fast is in. I only talk about constants for a short section where I write about a particular way (anti-pattern even) to configure programs. The Readonly module hasn’t been updated in years. It uses tie to perform its magic and has several interesting edge cases from that as you can see in its RT queue. Leon Timmermans replaced it with Const::Fast. It uses almost the same interface but “by doing everything the opposite way Readonly does it.” I’ve asked Eric Roode, Readonly‘s maintainer, if I can get it into Github and have the community update it. I’ll see how that goes.

In two places I had mentioned Google Code Search, the now dead project that was part of Google’s mission to “organize the world’s information and make it universally accessible and useful”. Instead, I found Ohloh’s code search. In the chapter, I look for “DON’T EDIT BELOW THIS LINE” and config.pl to show how common those are.

AppConfig is out. I don’t think it was widely used even when it was fresh, but it’s as old as the first edition of Mastering Perl. Instead, I mentioned JSON and YAML, although I’ll cover those in Chapter 14: Lightweight Persistence. I should survey people to see how they are configuring things nowadays.

Do you have anything else I should include or update? See what I have so far by reading it through 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.