Полезная информация

Learning Perl on Win32 Systems

Learning Perl on Win32 SystemsSearch this book
Previous: 13.2 Renaming a FileChapter 13
File and Directory Manipulation
Next: 13.4 Modifying Permissions
 

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: $!";


Previous: 13.2 Renaming a FileLearning Perl on Win32 SystemsNext: 13.4 Modifying Permissions
13.2 Renaming a FileBook Index13.4 Modifying Permissions