On Files and Directories
Perl has an extensive set of built-in functions that deal with files and directories. We discuss some of these functions in this chapter.
We have seen in earlier chapters how to read from a file and write to a file. We can copy a file by reading from it and then writing to another. In this chapter, we see that we can perform many operations on files and directories directly without having to read or write lines of content. What we discuss here works in the Unix environment including Macintosh OS X. They should mostly work in other environments such as IBM-compatible PCs and pre-OS X Macintoshes, but are not guaranteed to do so. This chapter also illustrates that recursive programming can be a natural tool in handling a graph such as a directory structure on a computer. There are many examples of recursive subroutines in this
chapter. The chapter is primarily devoted to the study of directories and how to perform various operations on them.