sub gettag { # ... # ... only an extract ... my $push = !defined( $self -> { DEPTH } ); $push ||= ( ( $self -> { DEPTH } ) <= ( $self -> { THIS }{ DEPTH } ) ); while ( !$simple # already deemed as nested type && ( $$bufref =~ /^\<(.)/ ) && ($1 ne '/' ) ) { my $subtag = $self -> gettag(); $push and push @subtags, $subtag; Throw( $self ); } my $tref = { $tag => { ASSMNTS => $assignments, SUBTAGS => \@subtags } }; $push or PutEnvelope( $self, $tref ); # i.e. it is 'marked' as an enclosing tag # ... end of extract ... # ... } #### sub PutEnvelope { # store "ignored" outer tag for later use by puttag my $self = shift; my $tref = shift; my $envtag = keys %$tref; my $depth = 1; my $eref = ( ( $self -> { ENVELOPE } ) ||= {} ); for ( ;( $depth < ( $self -> { THIS }{ DEPTH } ) ); $depth++ ) { my $k = ( keys %$eref ) || $;; $eref = ( $eref -> { $k }{ SUBTAGS }[0] ||= undef() ); } $eref -> { $envtag } ||= ( $eref -> { $; } ||= undef() ); $eref -> { $envtag }{ ASSMNTS } = $tref -> { ASSMNTS }; # envelope tags must preserve assignments delete $eref -> { $; }; # replace any $; at same level. }