In addition to the functions I've described in this lesson and on Day 15, all of which are described in the perlfunc man page, there are also quite a few modules in the standard module library for managing files and file handles.
Many of these modules are simply object-oriented wrappers for the standard file operations; others are especially useful for covering up or getting around cross-platform issues. Still others simply provide convenience functions for managing files and directories.
I've mentioned a number of these modules previously in this chapter—Getopt and Cwd in particular. Table 17.2 shows the more complete list; for details on any of these modules, see the perlmod man page.
Module Name | What it Does |
---|---|
Cwd | Finds out the current working directory in a safe, cross-platform way |
DirHandle | An object-oriented wrapper for manipulating directory handles |
File::Basename | Allows you to parse file and directory path names in a cross-platform manner |
File::CheckTree | Performs multiple file tests on a group of files |
File::Copy | Copies files or file handles |
File::Find | Similar to the Unix find command, traverses a directory tree to find a specific file that matches a specific pattern |
File::Path | Creates or removes multiple directories or directory trees |
FileCache | Some systems might not let you have large numbers of files open at once; this gets around that limit. |
FileHandle | An object-oriented wrapper for manipulating file handles |
Getopt::Long | Manages script arguments (complicated POSIX syntax) |
Getopt::Std | Manages script arguments (simpler single-character syntax) |
SelectSaver | Saves and restores file handles (used with the select function. We'll look at select on Day 20, “Odds and Ends” |