in reply to Predefining complex data structures?

First, don't pre-define. Let Perl do the auto-vivification for you. That's what it's there for. Especially because you don't know for certain what will be there, just what structure it will be in.

Secondly, you want to do something along the lines of:

# Caveat Lector - this is untested! foreach $tag (@tags) { push @{$tagstack{$tag->name}}, { text => $tag->value, attributes => { split /[\s=]+/, $tag->attributes }, }; }
Obviously, I'm assuming that $tag is some object with three methods - name(), value(), and attributes(). These will have to return the appropriate values from the data source. Also, I'm assuming that attributes() will return everything within the tag definition other than the tag's name. If all you get is the text, you could do something like:
foreach my $tag (@tags) { my ($name, $attributes, $value) = $tag =~ m#^<(\w+)\s+(\w+)?\s*>(.*?)</\1>$#; # Use $name, $attributes, and $value as per above }
The regex could be tightened, but this is off-the-cuff.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.