slugger415 has asked for the wisdom of the Perl Monks concerning the following question:

Hello esteemed monks, I'm learning XML::Twig and have not been able to figure out how to insert an element in a particular location other that first_child or last_child. For example, here is my XML source:

<concept> <title>My Title</title> <prolog>some other info</prolog> </concept>

I want to insert a new element "short_desc" in between "title" and "prolog". How do I do that?

I can do this using first_child and last_child thusly:

my($twig,$con) = @_; $con->insert_new_elt('first_child','short_desc' =>{ AAA => 'hello'});

which results in

<short_desc AAA="hello"/> <title>Bat sonar</title> <prolog>some other info</prolog>

but what I want is:

<title>Bat sonar</title> <short_desc AAA="hello"/> <prolog>some other info</prolog>

Any pointers appreciated. I have been scanning the Twig doc but am not sure what to look for. I see mention of $opt_position but this is not defined anywhere. (The xml twig site seems to have been dead for a while...)

Thank you -- Scott