home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


13.3 Making and Removing Directories

You probably couldn't have made it this far without knowing about the mkdir or md command, which makes directories that hold other filenames and other directories. Perl's equivalent is the mkdir function, which takes a name for a new directory and a mode that will affect the permissions of the created directory. The mode is specified as a number interpreted in internal permissions format. For now, just say 0777 for the mode and everything will work. Here's an example of how to create a directory named gravelpit :

mkdir("gravelpit",0777) || die "cannot mkdir gravelpit: $!";

The command-prompt rmdir command removes empty directories - you'll find a Perl equivalent with the same name ( rmdir ). Here's how to make Fred unemployed:

rmdir("gravelpit") || die "cannot rmdir gravelpit: $!";