in reply to Re: XML::Twig replace method behaving counter-intuitively
in thread XML::Twig replace method behaving counter-intuitively
The cut did the trick! :) FYI, the thing that threw me was the difference in the wording of the documentation for the paste and replace methods, as shown on CPAN. The paste method makes it clear that you can only paste previously-cut elements (of course), but the replace method says "Sometimes it is just not possible tocut[sic] an element then paste another in its place, so replace comes in handy." I interpreted this to mean that replace was analogous to cut and paste, when you wanted to paste over another element. If I may recommend a simple change to the line that precedes it, to give it context: "Replaces an element in the tree." -> "Replaces an element in the tree with a previously cut element." (or whatever the general case is)
Thanks for the array syntax pointer - it's a bad habit of mine, and I'll debug with -w from now on :)
I completely missed the information that the current twig is passed into the subroutine, but I'm glad I know now.
I did run into a problem executing the new code that looks for the previous matching element: $this_tweak->previous_sibling( qq{tweak[\@name="$tweak_name"]})
Do I need to define that method myself?$ ./twig_replace_test.pl Can't locate object method "previous_sibling" via package "XML::Twig:: +Elt" at ./twig_replace_test.pl line 14.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: XML::Twig replace method behaving counter-intuitively
by mirod (Canon) on Dec 04, 2007 at 18:56 UTC | |
by Human (Initiate) on Dec 04, 2007 at 20:58 UTC | |
by Human (Initiate) on Dec 04, 2007 at 20:31 UTC |