No::Worries::Dir - directory handling without worries
use No::Worries::Dir qw(dir_change dir_ensure dir_make dir_parent dir_read dir_remove); # change directory dir_change("/tmp"); # make sure a directory exists (not an error if it exists already) dir_ensure("/tmp/some/path", mode => 0770); # make a directory (an error if it exists already) dir_make("/tmp/some/path", mode => 0770); # find out the parent directory of some path $parent = dir_parent($path); dir_ensure($parent); # read a directory foreach $name (dir_read("/etc")) { ... } # remove a directory dir_remove("/tmp/some/path");
This module eases directory handling by providing convenient wrappers around standard directory functions. All the functions die() on error.
This module provides the following functions (none of them being exported by default):
change the working directory to the given path; this is a safe thin wrapper on top of chdir()
make sure the given path is an existing directory, creating it (including its parents) if needed; supported options:
mode: numerical mode to use for mkdir() (default: 0777)
mode
make the given directory; this is a safe thin wrapper on top of mkdir(); supported options:
return the parent directory of the given path
read the given directory and return its list of entries except . and ..
.
..
remove the given directory (that must exist and be empty); this is a safe thin wrapper on top of rmdir()
No::Worries.
Lionel Cons http://cern.ch/lionel.cons
Copyright CERN 2012
To install No::Worries, copy and paste the appropriate command in to your terminal.
cpanm
cpanm No::Worries
CPAN shell
perl -MCPAN -e shell install No::Worries
For more information on module installation, please visit the detailed CPAN module installation guide.