Thread

Posted on Thu Aug 16 00:33:35 2007 by jeunice
Determining if twig has been modified
Is there any easy way to test whether a twig has been modified? I searched the POD for "changed" and "modified" but found no method. Currently I am just assuming that if a program MIGHT modify the twig, then it DID modify the twig, regardless of whether it did or not.
Direct Responses: 5904 | Write a response
Posted on Thu Aug 16 21:07:53 2007 by mirod in response to 5894
Re: Determining if twig has been modified

At the moment there is nothing that tells you whether a twig was changed, and adding that would be both difficult and bad for performances. What you can do is set a flag in any piece of code that would modify the twig. Maybe you could even automate that to a point by using Hook::LexWrap or something similar. An other option is to subclass XML::Twig::Elt and to redefine the methods that are likely to be used to change the twig (once again, you could use Hook::LexWrap to do this automagically) so they set a flag. Saddly enough the complete list of those methods doesn't exist, and is pretty long. Plus what happens if, for example, you cut an element and then paste it back in the same position?

If you posted a detailed example, I could probably suggest some other ways to do this (how about diffing the input xml and the output, if they aren't too big?).

--
mirod

Direct Responses: 5916 | Write a response
Posted on Sat Aug 18 12:26:05 2007 by jeunice in response to 5904
Re: Determining if twig has been modified
OK, understood. The phrase "any piece of code that would modify the twig" says it all. Basically, my entire program. ;-) Will file this under "pretty thought, just not practical." Performance is already good, so it will be easy to rewrite twigs even if there is no change.
Write a response