HTML CSS PHP PERL

Hour 10. Files and Directories

 
Previous Table of Contents Next

Hour 10. Files and Directories

What You'll Learn in This Hour

Files in your operating system provide a convenient set of storage concepts for data. The OS enables a name to be given to the data (a filename) and provides an organizational structure, called a file system, so that you can find the data later. Your computer's file system then organizes files into groups called directoriessometimes called folders. These directories can store files or other directories.

This nesting of directories inside directories provides a treelike structure to the file system on your computer. Each file is part of a directory, and each directory is part of a parent directory. In addition to providing an organizational structure for your files, the operating system also stores data about the file: when the file was last read, when it was last modified, who created it, the current size of the file, and so oncalled metadata (see Hour 5, "Working with Files"). This organization is true of almost all modern computer operating systems.

In the case of the Macintosh (pre-Mac OS X), this structure still holds true, except that the top-level directory is called a Volume, and the subdirectories area is called Folders.

Perl allows you to access this structure, modify the organization, and examine the information about the files. The functions that Perl uses for these tasks are all derived from the Unix operating system, but they work just fine under whatever operating system Perl happens to be running on. Perl's file system manipulation functions are portable, meaning that if you use Perl's functions to manipulate your files and query them, you should have no problems running your code under any operating system Perl supports, providing that the directories are structured similarly.

    Previous Table of Contents Next
    © 2000- NIV