Learning Perl on Win32 Systems

Learning Perl on Win32 SystemsSearch this book
Previous: 11.6 Changing Defaults for FormatsChapter 11
Formats
Next: 11.8 Exercises
 

11.7 The FileHandle Module

Because Perl was designed to be a practical extraction and report language, formats were one of the earliest constructs incorporated into the language. As such, the format interface is starting to show its age, particularly when you have to resort to ugly variable names and esoteric select manipulations merely to switch the currently active format.

The FileHandle module provides a more intuitive approach to these matters. For example, here's the easy way to perform the same manipulations we demonstrated earlier in the section "Changing the Format Name."

use FileHandle; # load library

format_name REPORT "ADDRESSLABEL";
write REPORT;

format_name REPORT "SUMMARY";
write REPORT;

This object-oriented module lets you treat filehandles as though they were objects.[5] All the filehandle-specific built-in punctuation variables have more mnemonic interfaces. See Chapter 2 of Programming Perl, or the perlform documentation, for the complete description of these.

[5] See Chapter 18, CGI Programming, for more explanation about objects.


Previous: 11.6 Changing Defaults for FormatsLearning Perl on Win32 SystemsNext: 11.8 Exercises
11.6 Changing Defaults for FormatsBook Index11.8 Exercises