Perl File Handling Functions chmod(mode, file_list) Changes the permissions of a list of files. e.g chmod(0755,"file1"); truncate(FILE,SIZE) Truncates FILE to SIZE. FILE may be a filename or a filehandle. link(OLDFILE,NEWFILE) Creates a new filename linked to the old filename. symlink(OLDFILE, NEWFILE) Creates a new filename symbolically linked to the old filename. rename(OLDNAME, NEWNAME) Changes the name of a file. unlink(file_list) Deletes a list of files. Perl File Handling: stat( ) stat(FILE) Returns a 13-element array : ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks). FILE can be a filehandle, an expression evaluating to a filename. $dev device $ino inode number $mode permissions $nlink link count $uid user id $gid group id $rdev raw device $size file size $atime last access time $mtime last modification time $ctime last status change time $blksize block size $blocks number of blocks File/Directory Attributes Test -x Perl uses -x to test for file/directory attributes, where x -r readable -w writeable -x executable -o owned by user -e exists -z exists and zero size -s exists, non-zero size -d directory -l symbolic link -S socket -T text file -B binary -M modification age in days -A access age in days e.g $file = "file_name"; if (-e $file) { } else {print "file missing"} # tests if the file exists Perl Directory Handling Functions opendir(DIRHANDLE,directory_name) Opens a directory on the handle specified. closedir(DIRHANDLE) Closes a directory opened by opendir. readdir(DIRHANDLE)* Returns the next entry (or an array of entries) in the directory. rewinddir(DIRHANDLE)* Positions the directory to the beginning seekdir(DIRHANDLE,position)* Sets position for readdir on the directory. telldir(DIRHANDLE)* Returns the position in the directory.