File::Slurp::Tree - slurp and emit file trees as nested hashes
# (inefficiently) duplicate a file tree from path a to b use File::Slurp::Tree; my $tree = slurp_tree( "path_a" ); spew_tree( "path_b" => $tree );
File::Slurp::Tree provides functions for slurping and emitting trees of files and directories.
# an example of use in a test suite use Test::More tests => 1; use File::Slurp::Tree; is_deeply( slurp_tree( "t/some_path" ), { foo => {}, bar => "sample\n" }, "some_path contains a directory called foo, and a file bar" );
The tree datastructure is a hash of hashes. The keys of each hash are names of directories or files. Directories have hash references as their value, files have a scalar which holds the contents of the file.
return a nested hash reference containing everything within $path
%options may include the following keys:
a File::Find::Rule object that will match the files and directories in the path. defaults to an empty rule (matches everything)
Creates a file tree as described by $tree at $path
$tree
$path
None currently known. If you find any please contact the author.
Richard Clamp <richardc@unixbeard.net>
Copyright (C) 2003, 2006 Richard Clamp. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
File::Slurp, Test::More
To install File::Slurp::Tree, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::Slurp::Tree
CPAN shell
perl -MCPAN -e shell install File::Slurp::Tree
For more information on module installation, please visit the detailed CPAN module installation guide.