in reply to parsing XMLish data
For the same reasons, I was a bit scared off mirod's idea, there is anywhere between 10 and 30 columns I'm looking for so going through the data file and adding the CDATA sections seems a bit inefficient. I will bear this idea in mind, I'm tempted to try and change the data files to use these.
The best I can come up with is a single loop:
while (/<([^>]+)>/g) { if ($1 eq '/r') { print Dumper(\%temp); undef %temp; } else { next unless $wanted{$1}; if (substr($1, 0, 1) eq '/') { my $text = substr($_,$pos,pos()-$pos-length($1)-2); $temp{substr($1, 1)} = $text; } else { $pos = pos(); } } }
gav^
|
|---|