The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

File::Slurp::Tree - slurp and emit file trees as nested hashes

SYNOPSIS

 # (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 );

DESCRIPTION

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.

EXPORTED ROUTINES

slurp_tree( $path, %options )

return a nested hash reference containing everything within $path

%options may include the following keys:

rule

a File::Find::Rule object that will match the files and directories in the path. defaults to an empty rule (matches everything)

spew_tree( $path => $tree )

Creates a file tree as described by $tree at $path

BUGS

None currently known. If you find any please make use of http://rt.cpan.org by mailing your report to bug-File-Slurp-Tree@rt.cpan.org, or contact me directly.

AUTHOR

Richard Clamp <richardc@unixbeard.net>

COPYRIGHT

Copyright (C) 2003 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.

SEE ALSO

File::Slurp, Test::More