# As each tweak tag is processed, this subroutine is called. Here we will # see if any previous tweak tag had the same name attribute. If so, we will # replace the previous tweak tag with this new tweak tag's contents. sub pruner { my ($twig, $this_tweak) = @_; my $tweak_name = $this_tweak->att('name'); my $previous_tweak = $this_tweak->prev_sibling( qq{tweak[\@name="$tweak_name"]}); # If the tweak's name is found elsewhere, replace the first # instance with the latest one, then delete the latest one. if ($previous_tweak) { print "\tReplacing\n\t\t" if $debug; $previous_tweak->print if $debug; print "\n\twith\n\t\t" if $debug; $this_tweak->print if $debug; print "\n" if $debug; $this_tweak->cut; $this_tweak->replace($previous_tweak); } }