Skip Menu | will be shut down on March 1st, 2021.

This queue is for tickets about the Tree-Builder CPAN distribution.

Report information
The Basics
Id: 69928
Status: resolved
Priority: 0/
Queue: Tree-Builder

Owner: Nobody in particular
Requestors: emazep [...]

Bug Information
Severity: Critical
Broken in: 0.0.0
Fixed in: (no value)

Subject: Unquoted split regex et al.
Download (untitled) / with headers
text/plain 1.1k
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
Download (untitled) / with headers
text/plain 146b
Howdy! This has been fixed in 0.1.0. I added a non-sucky example and noted separator is a regexp and may be worth using quotemeta etc. Thanks!
Download (untitled) / with headers
text/plain 374b
OK, accepting (and documenting) the separator as a regex is probably the best option. Sorry for my late, but another useful option would be to let the user to escape/quote the separator, where he wants it to be skipped. This is easily accomplished using Data::Record instead of the split() builtin. Thanks for your quick fix! :-)

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to