Getting Started
Introduction
Perl IDEs
History
Advice
Tools
Mini-Tutorial
Tutorial
Code Snippets

Resources
Top Sites
More Tutorials
Books
Magazines
Articles
NewsLetters
Mailing Lists
NewsGroups
Forums
User Groups
Talk Shows
Blogs
Clothing

GBIC >> Perl >> Information Center Tutorials >> Directory Handling

Perl Information Center Tutorials - Directory Handling
These tutorials were written to help you get a quick, but thorough, understanding of Perl - the scope of the language as well as it's specific capabilities.

Beginners Built-In Functions     Advanced CGI Applications

Directories
Perl offers more functions that deal with files, I/O, and directory management than any other capability it supports. This wide variety of file functions is supplemented by some of the most terse (does more in fewer words - that's good!) syntax of any language, making file and directory I/O operations extremely easy.

    • Open/Close
     closedir, opendir
    • Random Access   
     readdir, rewinddir, seekdir, telldir
    • Directory Changes
     chdir, chroot, mkdir, rmdir

Directory Handling Syntax

Directory Functions Reference
Here's a quick reference of the available directory functions, in alphabetical order.

Unless otherwise noted, these functions operate on $_ by default.

  • chdir - change the current working directory
        chdir EXPR
        
  • chroot - make directory new root for path lookups
        chroot FILENAME
        
  • closedir - close directory handle
        closedir DIRHANDLE
        
  • mkdir - create a directory
        mkdir FILENAME, MASK         # mask defaults to 0777
        
  • opendir - open a directory
        opendir DIRHANDLE, EXPR
        
  • readdir - get a directory from a directory handle
        readdir DIRHANDLE
        
  • rewinddir - reset directory handle
        rewinddir DIRHANDLE
        
  • rmdir - remove a directory
        rmdir FILENAME
        
  • seekdir - reposition directory points
        seekdir DIRHANDLE, POS
        
  • telldir - get current seekpointer on a directory handle
        telldir DIRHANDLE
        

If you have any suggestions or correction, please let me know.