Learning Perl, 8th Edition

O’Reilly Media is going ahead with Learning Perl, 8th Edition to cover v5.32, and to be perhaps the last edition of the title if Perl 7 works out (which you can read about in Preparing for Perl 7 from PerlSchool). This would be the fifth iteration of Tom Phoenix’s original vision that become the third edition. After this edition, I think a completely new text might be in order. That’s a way off though.

O’Reilly also wants to add some notes, where appropriate, about possible ways to do things for Perl 7. Since Perl 7 is basically v5.32 with different defaults, that’s not that hard.

Some things of I want to update, along with any minor things I might need to change. Nothing major, and some of these I might decide are a bad idea at this level:

Debuggex visualizes regular expressions

Debuggex can turn PCRE regular expressions into railroad diagrams. It’s missing several advanced Perl features, but it’s good for the basic patterns you’ll create in Learning Perl:

Bonus @INC directories

Marek Rouchal wrote to me with an interesting addendum to my previous post Who makes it into @INC first?. Besides the different ways to add directories, some of them also load additional subdirectories that you don’t specify.

» Read more…

Who makes it into @INC first?

Perl finds modules by looking through the list of directories in @INC. There are many ways to add paths to that array, and although I’ve used all of them at some point, I’ve never quite thought about what happens when I use all of them together.

Remember that Perl uses the first matching module name it finds then
stops looking. It does not have a designed way to determine a best match and newest match or anything fancy. Whatever it finds first is the winner. This also means that someone could add paths to @INC and force your program to run their version of a module, even maliciously. This is something I write about in the “Secure Programming Techniques” chapter of Mastering Perl.

» Read more…

Copy instead of renaming to preserve hard links

Yesterday I posted about not overwriting a file until you knew you had completely and correctly stored its data. Part of that was about data security and another part was completeness for other consumers. I used a temporary file and rename to move the new file into place. That’s not the entire story though.

» Read more…