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

Report information
The Basics
Id:
69928
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
emazep [...] gmail.com
Cc:
AdminCc:

BugTracker
Severity:
Critical
Broken in:
0.0.0
Fixed in:
(no value)



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
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!
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 http://search.cpan.org/dist/Data-Record/ instead of the split() builtin. Thanks for your quick fix! :-)


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.