I've been using $foo->paste('last_child', $bar) to graft subtrees onto a larger tree and it's been working as expected. That is, the paste will *copy* the contents of foo onto bar.
Now, it seems that the paste is using a pointer of foo to the bar tree. Since foo is populated within a loop with a "new" for foo at the start of the iteration, each time the new is hit, the contents of the prior foo (now attached to bar) vanishes. What persists on bar is only the value of foo.
Strangely, the population of the nodes within foo is done via the same paste/last-child mechanism, but this works as expected.
Can someone clarify this? Or am I doing something wrong? Thanks.
my $objectsTwig = new XML::Twig;
$OBJECTS_ROOT = $objectsTwig->root;
my $object = new XML::Twig;
$OBJECT_ROOT = $object->root;
... Add elements to <object> node
} until (yada...);