perlfunc
root
<P>
File::Path - create or remove a series of directories
<P>
<HR>
<P>
<CODE>use File::Path</CODE>
<P>
<CODE>mkpath(['/foo/bar/baz', 'blurfl/quux'], 1, 0711);</CODE>
<P>
<CODE>rmtree(['foo/bar/baz', 'blurfl/quux'], 1, 1);</CODE>
<P>
<HR>
<P>
The <CODE>mkpath</CODE> function provides a convenient way to create directories, even if your [perlfunc:mkdir|mkdir] kernel call won't create more than one level of directory at a time. <CODE>mkpath</CODE> takes three arguments:
<UL>
<LI>
<P>
the name of the path to create, or a reference to a list of paths to
create,
<P><LI>
a boolean value, which if
<FONT SIZE=-1>TRUE</FONT> will cause <CODE>mkpath</CODE>
to print the name of each directory as it is created (defaults to
<FONT SIZE=-1>FALSE),</FONT> and
<P><LI>
the numeric mode to use when creating the directories (defaults to 0777)
</UL>
<P>
It returns a list of all directories (including intermediates, determined
using the Unix '/' separator) created.
<P>
Similarly, the <CODE>rmtree</CODE> function provides a convenient way to delete a subtree from the directory
structure, much like the Unix command <CODE>rm -r</CODE>.
<CODE>rmtree</CODE> takes three arguments:
<UL>
<LI>
<P>
the root of the subtree to delete, or a reference to a list of roots. All
of the files and directories below each root, as well as the roots
themselves, will be deleted.
<P><LI>
a boolean value, which if
<FONT SIZE=-1>TRUE</FONT> will cause <CODE>rmtree</CODE> to print a message each time it examines a file, giving the name of the
file, and indicating whether it's using [perlfunc:rmdir|rmdir]
or [perlfunc:unlink|unlink] to remove it, or that it's skipping it. (defaults to
<FONT SIZE=-1>FALSE)</FONT>
<P><LI>
a boolean value, which if
<FONT SIZE=-1>TRUE</FONT> will cause <CODE>rmtree</CODE> to skip any files to which you do not have delete access (if running under
<FONT SIZE=-1>VMS)</FONT> or write access (if running under another
<FONT SIZE=-1>OS).</FONT> This will change in the future when a criterion for 'delete permission' under OSs other than
<FONT SIZE=-1>VMS</FONT> is settled. (defaults to
<FONT SIZE=-1>FALSE)</FONT>
</UL>
<P>
It returns the number of files successfully deleted. Symlinks are treated
as ordinary files.
<P>
<STRONG>NOTE:</STRONG> If the third parameter is not
<FONT SIZE=-1>TRUE,</FONT> <CODE>rmtree</CODE> is <STRONG>unsecure</STRONG>
in the face of failure or interruption. Files and directories which were
not deleted may be left with permissions reset to allow world read and
write access. Note also that the occurrence of errors in rmtree can be
determined <EM>only</EM> by trapping diagnostic messages using <CODE>$SIG{__WARN__}</CODE>; it is not apparent from the return value. Therefore, you must be
extremely careful about using <CODE>rmtree($foo,$bar,0</CODE>
in situations where security is an issue.
<P>
<HR>
<H1><A NAME="AUTHORS">AUTHORS</A></H1>
<P>
Tim Bunce <<EM>Tim.Bunce@ig.co.uk</EM>> and Charles Bailey <<EM>bailey@genetics.upenn.edu</EM>>
<P>
<HR>
<H1><A NAME="REVISION">REVISION</A></H1>
<P>
Current <CODE>$VERSION</CODE> is 1.0401.
<HR>