Perl Directory Reading Functions

by Geethalakshmi 2010-09-17 12:30:23

Perl Directory Reading Functions


chdir(EXPR)
chdir EXPR
chdir
Changes the working directory to EXPR, if possible. If EXPR is omitted, changes to home directory. Returns 1 upon success, 0 otherwise. See example under die.

closedir(DIRHANDLE)
closedir DIRHANDLE
Closes a directory opened by opendir().

mkdir(FILENAME,MODE)
Creates the directory specified by FILENAME, with permissions specified by MODE (as modified by umask). If it succeeds it returns 1, otherwise it returns 0 and sets `$!' (errno).

opendir(DIRHANDLE,EXPR)
Opens a directory named EXPR for processing by readdir(), telldir(), seekdir(), rewinddir() and closedir(). Returns true if successful. DIRHANDLEs have their own namespace separate from FILEHANDLEs.

readdir(DIRHANDLE)
readdir DIRHANDLE
Returns the next directory entry for a directory opened by opendir(). If used in an array context, returns all the rest of the entries in the directory. If there are no more entries, returns an undefined value in a scalar context or a null list in an array context.
rewinddir(DIRHANDLE)
rewinddir DIRHANDLE
Sets the current position to the beginning of the directory for the readdir() routine on DIRHANDLE.

rmdir(FILENAME)
rmdir FILENAME
rmdir
Deletes the directory specified by FILENAME if it is empty. If it succeeds it returns 1, otherwise it returns 0 and sets `$!' (errno). If FILENAME is omitted, uses `$_'.

seekdir(DIRHANDLE,POS)
Sets the current position for the readdir() routine on DIRHANDLE. POS must be a value returned by telldir(). Has the same caveats about possible directory compaction as the corresponding system library routine.

telldir(DIRHANDLE)
telldir DIRHANDLE
Returns the current position of the readdir() routines on DIRHANDLE. Value may be given to seekdir() to access a particular location in a directory. Has the same caveats about possible directory compaction as the corresponding system library routine.

Tagged in:

667
like
0
dislike
0
mail
flag

You must LOGIN to add comments