Category Archives: Dynamic Subroutines

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: Read more »

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. Read more »

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.