Tricks of the Wizards

(Perl Tricks and Programming Technique)

Length: 3 hours

Prerequisites: Attendees should have basic familiarity with Perl's packages, references, modules, and objects, and should desire to become wizards.

Description

New and Improved for 2003!

This class will explore Perl's most unusual features. We'll look at some of the standard modules written by famous wizards like Tom Christiansen, Damian Conway, and Larry Wall, and learn what they're for and how they work.

First we'll investigate Perl's remarkable 'glob' feature. We'll see many uses of globs, including the 'Exporter' module, which everyone uses but hardly anyone understands. We'll discuss how to accomplish the same globby magic in Perl 6, which won't have globs.

After this we'll look at unusual uses of Perl's tie function, which scoops the brain out of an ordinary Perl array, hash, or filehandle, replacing it with your own concoction. We'll make hashes with case-insensitive keys, arrays that mirror the contents of a file, and filehandles that suppress annoying output.

Then we'll learn about AUTOLOAD, Perl's function of last resort. We'll see a tremendously useful application: How to generate the accessor methods of a class without writing pages of repetitive code. We'll see how Larry's Shell module uses AUTOLOAD to emulate the Unix shell inside Perl scripts, and how Damian Conway's NEXT module uses AUTOLOAD for method redispatch.

Section 4 discusses Perl's new "source filter" feature. This magic allows you to write Perl programs in any language, and translate them to Perl at the last moment. We'll add a switch statement to Perl and we'll see how Perl 5 can emulate the variable syntax of Perl 6.

The class will finish with nine very small but useful enchantments that take thirty seconds each.


Outline

Sample Slides

8 15 37 71 88 94 107 122

Some of these things might sound like things you have heard of before. But they are likely to be things that you haven't heard of before. With a few exceptions, I try to put a really strange twist on everything, even familiar tasks. The idea is that even if you don't want to do it my way, you have something to think about that might turn out to be useful in some other way.

The talk has evolved substantially over the years. Section 3 used to be about Perl's operator overloading feature, but the autoloading turned out to be more interesting, so I replaced it. Section 4 used to be titled Large Techniques; it was replaced with a new Source Filters section in 2003. All the slides for the removed sections are still in a 'bonus section' at the end of the printed materials. Corporate clients may request reinsertion of any of these sections.

Also new in 2003: I need no longer issue a disclaimer that I am merely passing on the tricks of the wizards, and I do not claim to be a wizard myself. As of summer 2002, I am a wizard.


Illustrations on this page are by W. W. Denslow.


Return to: Universe of Discourse main page | Perl Paraphernalia | Other Classes and Talks

mjd-perl-yak+@plover.com