NAME
Tree::Builder - Takes path like strings and builds a tree of hashes of hashes.
VERSION
Version 0.1.0
SYNOPSIS
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);
METHODS
new
This initializes the object.
args hash ref
seperator
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=>'\.'});
add
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";
}
addSub
This is a internal function.
getSeperator
This gets the current seperator being used.
Error checking does not need to be done on this.
my $seperator=$tb->getSeperator;
getTree
This fetches the tree.
my %hash=$tb->getTree;
setSeperator
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";
}
ERROR RELATED METHODS
error
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);
}
errorString
Returns the error string if there is one. If there is not, it will return ''.
if($tb->error){
warn('error: '.$foo->error.":".$foo->errorString);
}
errorblank
This is a internal function.
ERROR CODES
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.
1
No seperator specified.
2
Item to add not defined.
AUTHOR
Zane C. Bowers-Hadley, <vvelox at vvelox.net>
BUGS
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.
SUPPORT
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
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
Emanuele, #69928, for pointing out the crappy docs for 0.0.0
COPYRIGHT & LICENSE
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.