Mark-Jason Dominus, Chief Programmer, Plover Systems Co.
Date: Tuesday, July 24
Time: 8:30am - 12:00pm
Location: Portland 252
A powerful technique available to Perl programmers is writing functions that can manufacture or modify other functions. Instead of writing ten similar functions that must be maintained separately, you can write a single function that will create the others as needed. This class will teach you how.
The first section is about dynamically replacing functions with facades. Without changing a function's code, we can add caching behavior to it, or have it enforce an interface contract, or automatically track its own performance.
The second section is about iterators, which are functions for generating data a little bit at a time. For files, provides filehandles, but the technique is more generally applicable. As with filehandles, the technique is suitable when the total amount of data is too large to use all at once. This section ends by implementing an improved version of Perl's standard File::Find module. Unlike the usual implementation, the improved version can be stopped in the middle and resumed later as often as desired. Multiple searches can be active simultaneously, making it possible to recursively compare two separate directory structures.
The final section is about parsing. Perl's built-in utilities make it easy to parse simple inputs, but for more complex data a modular approach is more effective. A basic parser is a trivial function that transforms a simple input into a value. By writing functions that build more complex parsers from simple, interchangeable parts, we can easily built up a parser for any kind of input.