- mkdir FILENAME
Creates the directory specified by FILENAME, with permissions specified by MASK (as modified by
umask). If it succeeds it returns true; otherwise it returns false and sets
$!(errno). MASK defaults to 0777 if omitted, and FILENAME defaults to
In general, it is better to create directories with a permissive MASK and let the user modify that with their
umaskthan it is to supply a restrictive MASK and give the user no way to be more permissive. The exceptions to this rule are when the file or directory should be kept private (mail files, for instance). The perlfunc(1) entry on
umaskdiscusses the choice of MASK in more detail.
Note that according to the POSIX 1003.1-1996 the FILENAME may have any number of trailing slashes. Some operating and filesystems do not get this right, so Perl automatically removes all trailing slashes to keep everyone happy.
To recursively create a directory structure, look at the
make_pathfunction of the File::Path module.