Subject: | Unquoted split regex et al. |
Various bugs/warts
1.
The split regex should be quoted, otherwise if you use a metacharacter
as a separator, say a pipe:
use Tree::Builder;
my $tb = Tree::Builder->new( { seperator => '|' } );
$tb->add('fo|ba');
use Data::Dumper;
print Dumper( { $tb->getTree } );
you'll obtain:
$VAR1 = {
'f' => {
'o' => {
'|' => {
'b' => {
'a' => {}
}
}
}
}
};
with other metacharacters possibly generating even fatal errors.
To solve this, just change:
my @itemA=split(/$self->{seperator}/, $item);
into:
my @itemA = split( /\Q$self->{seperator}/, $item );
2.
At first glance, the code looks unfinished: for example new() contains
the following snippet:
if (defined($args{seperator})) {
}
could you please clean your code up?
3.
The synopsis contains at least a couple of bugs (it doesn't even
compile): could you please fix it?
---
If cared for a little bit more, this module would be extremely useful.
Thanks anyway!
-Emanuele