Tree::Builder - Takes path like strings and builds a tree of hashes of hashes.
Version 0.1.0
use Tree::Builder; my $tb = Tree::Builder->new(); $tb->add('a/b/c'); $tb->add('some/thing'); $tb->add('a/some/thing'); my %tree=$tb->getTree; print $tb->getSeperator; $tb->setSeperator('\.'); $tb->add('what.ever'); #prints it using Data::Dumper use Data::Dumper; print Dumper(\%tree);
This initializes the object.
This is the seperator, regexp, to use for breaking a string down and hadding it to the tree.
If not specified, the default is '\/'.
Be warned, this is a regular expression, so if you don't want it to act as such, you will want to use quotemeta.
#initiates it with the defaults my $tb=Tree::Builder->new; #initiaties it with a seperator of . my $tb=Tree::Builder->new({seperator=>'\.'});
This adds a new item to the tree.
In regards to error checking, there is no need to check this for errors as long as you make sure that the string passed to it is defined.
$tb->add("some/thing"); if($tb->{error}){ print "Error!\n"; }
This is a internal function.
This gets the current seperator being used.
Error checking does not need to be done on this.
my $seperator=$tb->getSeperator;
This fetches the tree.
my %hash=$tb->getTree;
As long as this is defined, there is no need to check if it errored or not.
$tb->setSeperator('\/'); if($tb->{error}){ print "Error!\n"; }
Returns the current error code and true if there is an error.
If there is no error, undef is returned.
if($tb->error){ warn('error: '.$foo->error.":".$foo->errorString); }
Returns the error string if there is one. If there is not, it will return ''.
As all error codes are positive, $tb->error can be checked to see if it is true and if it is, then there is an error.
No seperator specified.
Item to add not defined.
Zane C. Bowers-Hadley, <vvelox at vvelox.net>
<vvelox at vvelox.net>
Please report any bugs or feature requests to bug-tree-builder at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tree-Builder. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-tree-builder at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Tree::Builder
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Tree-Builder
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Tree-Builder
CPAN Ratings
http://cpanratings.perl.org/d/Tree-Builder
Search CPAN
http://search.cpan.org/dist/Tree-Builder/
Emanuele, #69928, for pointing out the crappy docs for 0.0.0
Copyright 2011 Zane C. Bowers-Hadley, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Tree::Builder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tree::Builder
CPAN shell
perl -MCPAN -e shell install Tree::Builder
For more information on module installation, please visit the detailed CPAN module installation guide.