if($xref->att('keyref')){ my($h) = $linktext{$xref->att('keyref')}; # the keyref att is the key previously defined for the %linktext hash my($count); foreach my $i (@$h){ $count++; print "child $count:\n"; $i->print; print $/; $xref->copy->paste(last_child=>$i); # this is where I must be doing something wrong! } $xref->print; } #### child 1: child 2: Database- child 3: level child 4: privileges #### Database-level privileges #### my @children = $citeReference->children; $linktext{citeReference->att('keys')} = \@children; #### some existing text that should get replaced #### Database-level privileges #### if($xref->att('keyref')){ my($h) = $linktext{$xref->att('keyref')}; my($count); foreach my $i (@$h){ $count++; print "child $count:\n"; $i->print; print $/; $xref->copy->paste(last_child=>$i); } $xref->print; } #### child 1: child 2: Database- child 3: level child 4: privileges Database-level privileges