Prev

Perl Notes

Next

Chapter 9.5 Creating a directory

You can use a script to creat a new directory that will accomodate new files.

To create a directory:

  1. Type mkdir(.
  2. Type directory, where directory is the name (and path, if necessary) of the new directory.
  3. Type 0oge, where 0 is a zero, and oge indicates the directory's initial permissions, before the umask takes affect. Generally you'll want to use 0777, which, with the standard umask of 22, will result in a directory with 755 permissions.
  4. Type ) to complete the function.
  5. Type ; to finsh the line.


if (-e "../tmp/archives") {
  print "The archives directory does exist.";
} else {
  print "The archives directory does NOT exist.";
  mkdir ("../tmp/archives"), 0777) || @ErrorMessage;
  print "The archives directory has been created.";
}

Tips


Prev Home Next