start page | rating of books | rating of authors | reviews | copyrights

Programming Perl

Programming PerlSearch this book
Previous: 7.2.30 File::Find - Traverse a File Tree Chapter 7
The Standard Perl Library
Next: 7.2.32 FileCache - Keep More Files Open Than the System Permits
 

7.2.31 File::Path - Create or Remove a Series of Directories

use File::Path;  mkpath(['/foo/bar/baz', 'blurfl/quux'], 1, 0711); rmtree(['/foo/bar/baz', 'blurfl/quux'], 1, 1);

The mkpath() function provides a convenient way to create directories, even if your mkdir (2) won't create more than one level of directory at a time. mkpath() takes three arguments:

It returns a list of all directories created, including intermediate directories, which are assumed to be delimited by the UNIX path separator, / .

Similarly, the rmtree() function provides a convenient way to delete a subtree from the directory structure, much like the UNIX rm -r command. rmtree() takes three arguments:

rmtree() returns the number of files successfully deleted. Symbolic links are treated as ordinary files.


Previous: 7.2.30 File::Find - Traverse a File Tree Programming Perl Next: 7.2.32 FileCache - Keep More Files Open Than the System Permits
7.2.30 File::Find - Traverse a File Tree Book Index 7.2.32 FileCache - Keep More Files Open Than the System Permits