in reply to Re: Moving elements with XML::Twig: Document root closing tag is duplicated on output -- solution
in thread [SOLVED] Moving elements with XML::Twig: Document root closing tag is duplicated on output
Pretty much what Tanktalus said earlier. This code is a vastly simplified example piece that reproduces the issue in question. I tried to trim out as much unnecessary cruft to make the example as small and concise as possible while still remaining relevant
In answer to some of your questions:
the live code has some additional processing that happens after the twig is processed. It would look something like the following simplified example:
sub { my $local_state = _move(@_); $global_state = _do_stuff_with_local_state($local_state->{SUMMARY}, \%VARS); 1; },Correct. The actual code passes extra variables to the twig processing subroutine in addition to the default TWIG and ELEMENT variables passed to the handler:
sub { _move(@_, $local_state, \%OPTIONS, $warning_flag); 1; },Pretty much what Tanktalus said earlier.
The function called by the handler returns '1' in my simplified example (instead of variables) because it is an explicit 'true' return value
The anonymous sub returns '1' because there are multiple twig handlers that may apply to a given twig:
'/shipment/box' => sub { _move(@_); 1; }, '/shipment/box[@location='Vault_111']' => sub { _moveAgain(@_); 1; },
Hope that clarifies things.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Moving elements with XML::Twig: Document root closing tag is duplicated on output -- further comments
by Discipulus (Canon) on Feb 23, 2016 at 08:35 UTC |