File::TreeBuilder - Build simple trees of files and directories.
version 0.02
use File::TreeBuilder qw(build_tree); our $contents_str = 'Bla'; build_tree($some_dir, q{ / "D2" . "F_in_D2", "contents" . "F_in_top" / "D1 with spaces" . "F_in_D1", $contents_str . "F with spaces in D1", $contents_str });
That creates the following directory structure:
$some_dir/ "D1 with spaces"/ F_in_D1 # Contains 'Bla'. "F with spaces in D1" # Contains 'Bla'. D2/ F_in_D2 # Contains 'contents'. F_in_top # Empty file (0 bytes).
This module is used for building small trees of files and directories by describing what is needed in a text string.
Builds a tree of directories and files under $dir according to the given $str. Returns an empty string if successful, an error message otherwise. See the SYNOPSIS for example usage.
$str
In $str, blank or empty lines or lines whose first non-blank character is a pound sign (#) are ignored. Lines beginning with a slash (/) indicate directories to be created, while dots (.) indicate files. Directories are created hierarchically, according to the indentation. Files are created in the directory hierarchically above them. Anything that follows the filename on the line will be evaluated and placed in the file as its contents.
#
/
.
Important:
our
my
None by default.
Luc St-Louis <lucs@cpan.org>
This software is copyright (c) 2011 by Luc St-Louis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install File::TreeBuilder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::TreeBuilder
CPAN shell
perl -MCPAN -e shell install File::TreeBuilder
For more information on module installation, please visit the detailed CPAN module installation guide.