in reply to Modifying Records with XML::SAX::ByRecord
my $category_stack = $self->{category_stack} ||= []; push @$category_stack, { some => $category, data => $here };
Then when you see a title and you're ready to finish work on the category you just pop it off:
my $category_stack = $self->{category_stack}; my $category_data = pop @$category_stack;
Using a stack allows categories to nest. Popping off the category data means the stack is conservative and will shrink as stored data is used. You definitely want to avoid building a data structure that can contain all the category data in your file.
Does that make sense?
-sam
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Modifying Records with XML::SAX::ByRecord
by Lorphos (Novice) on Sep 03, 2007 at 08:55 UTC |