I’ve been having quite a bit of fun with Redis, a lightweight and simple data structure server. It’s easy to install locally, but you can also get a free server from redislabs. Services such as Heroku can spin up Redis instances and use them with your Heroku-deployed Mojo applications. Continue reading “Redis provides lightweight, scalable persistent data structures”
Category: Chapters
More fun with the diamond operator
In The double diamond, a more secure <>, I showed how the diamond operator treated some characters as special when it tried to open the filenames in @ARGV
. I used a file name that ended with a |
to read the output for an external command.
Thinking about it more, I realized the problem is even worse. Opening an external command to read the output might even be useful. What if I start the filename with >
to open a file for writing, but not only writing, to truncate it to? Continue reading “More fun with the diamond operator”
The double diamond, a more secure <>
We’ve had the three argument open
since Perl 5.6. This allows us to separate the way we want to interact with the file from the filename. There’s a place where we don’t get to choose, but Perl 5.22 might introduce a new operator to handle that. Continue reading “The double diamond, a more secure <>“
The Data::Dumper stack smash (fixed)
Problems with data serializers was a major change to Mastering Perl. The Storable issue with malformed inputs was known for a long time but nobody much cared about it. Now it’s Data::Dumper‘s turn. Continue reading “The Data::Dumper stack smash (fixed)”
Sub::Install has a nice interface
I didn’t mention Sub::Install in the “Dynamic Subroutines” (or maybe the Symbol Table chapter. It was worth a mention (but only that). I show readers how to define subroutines in other packages (or even the current one, I guess) by assigning to a type glob: Continue reading “Sub::Install has a nice interface”
Naming anonymous subroutines
In the “Dynamic Subroutines” chapter, I considered adding the undocumented __ANON__
trick to give anonymous subroutines names. ysth described this in Permonks in 2003 in Named anonymous subs and later showed up in Perl Hacks #57. Although it’s undocumented, several modules use the trick. Continue reading “Naming anonymous subroutines”
Presentation: Parsing JSON with a single Perl regex
I’m giving a presentation from Mastering Perl while I’m in Houston next week.
- Thursday, October 17, 7pm
- cPanel, Inc. (3131 W. Alabama St.)
- Hosted by Houston Perl mongers
Perl v5.10 added several features that take (ir)regular expressions to a new level. With grammars and recursion, a single regex can now process things such as HTML and JSON. After going through these features, I’ll show how Randal Schwartz used them in his tiny JSON parser. This discussion also appears in chapter 2 of Mastering Perl, 2nd Edition, which you can read for free through O’Reilly’s Early Release program.
New to “Lightweight Persistence”
“Lightweight Persistence” has many changes. I covered Storable in the first edition, but since then it’s security problem has become more widely know. It’s easy to create a Storable file that can run unexpected code, for a couple of reasons.
Since I first wrote this book, YAML and JSON have become much more important, so I cover those. Continue reading “New to “Lightweight Persistence””
New to “Perl Debuggers”
I renamed this chapter to “Perl Debuggers” from “Debugging Perl”; it’s not really about the process of debugging but the tools to do it. Most of it has stayed the same, although I had to remove the unmaintained Devel::ebug::HTTP that uses old Catalyst code. That’s one of the reasons I don’t like tying such modules to frameworks. The people who like to make the frameworks like to reinvent them, leaving all of the legacy code behind.
You can read this chapter in O’Reilly Atlas.
New to “Profiling”
Devel::NYTProf, Adam Kaplan’s original creation and Tim Bunce’s ongoing gift to the Perl community, is the new star of my “Profiling” chapter. However, the static book format doesn’t do much to show it off.
Other than that, I went through all of the code and output with v5.18 to refresh it. Not much changed other than the times getting much faster almost a decade later.
You can read this chapter in O’Reilly Atlas.