: (), ".\n"
;
print $indent, " (Current lineage: ", join('/', @lineage_tags), ".)\n"
if DEBUG > 1;
if(DEBUG > 3) {
#my(
# $package, $filename, $line, $subroutine,
# $hasargs, $wantarray, $evaltext, $is_require) = caller;
print $indent,
" (Called from ", (caller(1))[3], ' line ', (caller(1))[2],
")\n";
}
#} else {
# $indent = ' ';
}
# End of if DEBUG
# Now actually do it
my @to_close;
if($tag eq '*') {
# Special -- close everything up to (but not including) the first
# limiting tag, or return if none found. Somewhat of a special case.
PARENT:
while (defined $p) {
$ptag = $p->{'_tag'};
print $indent, " (Looking at $ptag.)\n" if DEBUG > 2;
for (@stop) {
if($ptag eq $_) {
print $indent, " (Hit a $_; closing everything up to here.)\n"
if DEBUG > 2;
last PARENT;
}
}
push @to_close, $p;
$p = $p->{'_parent'}; # no match so far? keep moving up
print
$indent,
" (Moving on up to ", $p ? $p->{'_tag'} : 'nil', ")\n"
if DEBUG > 1;
;
}
unless(defined $p) { # We never found what we were looking for.
print $indent, " (We never found a limit.)\n" if DEBUG > 1;
return;
}
#print
# $indent,
# " (To close: ", join('/', map $_->tag, @to_close), ".)\n"
# if DEBUG > 4;
# Otherwise update pos and fall thru.
$self->{'_pos'} = $p;
} elsif (ref $tag) {
# Close the first of any of the matching tags, giving up if you hit
# any of the stop-tags.
PARENT:
while (defined $p) {
$ptag = $p->{'_tag'};
print $indent, " (Looking at $ptag.)\n" if DEBUG > 2;
for (@$tag) {
if($ptag eq $_) {
print $indent, " (Closing $_.)\n" if DEBUG > 2;
last PARENT;
}
}
for (@stop) {
if($ptag eq $_) {
print $indent, " (Hit a limiting $_ -- bailing out.)\n"
if DEBUG > 1;
return; # so it was all for naught
}
}
push @to_close, $p;
$p = $p->{'_parent'};
}
return unless defined $p; # We went off the top of the tree.
# Otherwise specified element was found; set pos to its parent.
push @to_close, $p;
$self->{'_pos'} = $p->{'_parent'};
} else {
# Close the first of the specified tag, giving up if you hit
# any of the stop-tags.
while (defined $p) {
$ptag = $p->{'_tag'};
print $indent, " (Looking at $ptag.)\n" if DEBUG > 2;
if($ptag eq $tag) {
print $indent, " (Closing $tag.)\n" if DEBUG > 2;
last;
}
for (@stop) {
if($ptag eq $_) {
print $indent, " (Hit a limiting $_ -- bailing out.)\n"
if DEBUG > 1;
return; # so it was all for naught
}
}
push @to_close, $p;
=9= |