in reply to purging of grandchildren in XML::Twig

PodMaster has already given solid answer base on his experience.

Now you may wondering what purge actually does. Method purge is used to blow entire section away. There is also a method called flush does similar thing, but they handles output differently.

XML::Twig uses memory very wisely, and purge and flush are part of the effort, so that you can quickly dispose a processed section if it is no longer needed.

By the way, there might be a typo in your code, is it? Looks you are getting both child and granchild from $tag.

  • Comment on Re: purging of grandchildren in XML::Twig

Replies are listed 'Best First'.
Re: Re: purging of grandchildren in XML::Twig
by Skeeve (Parson) on Oct 20, 2003 at 06:36 UTC
    That's what I wanted to do: Blow away an entire subtree. Example: If I have
    root +--X1 | +--Y1 | | +--Z1 | | \--Z2 | | | +--Y2
    and I'm currently in the root-node-handler, I may blow away all the Y's and everything below the Y's. So what I finally came up with is
    $t->purge_up_to($grandchild);
    And yes you're right: It was a typo.