Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: XML::Twig - provide additional parameters to twig_roots handlers

by Jenda (Abbot)
on Oct 01, 2012 at 07:11 UTC ( [id://996592]=note: print w/replies, xml ) Need Help??


in reply to XML::Twig - provide additional parameters to twig_roots handlers

This has been discussed about two weeks ago in XML::Twig newbie question.

Jenda
Enoch was right!
Enjoy the last years of Rome.

  • Comment on Re: XML::Twig - provide additional parameters to twig_roots handlers

Replies are listed 'Best First'.
Re^2: XML::Twig - provide additional parameters to twig_roots handlers
by kejv2 (Acolyte) on Oct 01, 2012 at 19:29 UTC
    Ah, so the solution is to use slight closure trick instead of being provided by the module itself, but that's ok. It's a pity that the topic you are referencing isn't properly named. Otherwise I could have maybe found the info myself...

      The thing is that you may very well want to have several different twig roots with different handlers and different piece of data to pass. XML::Twig could have given you a "pad" within the parser object that you could use to store something in between the handler calls, but (at least according to a quick scan ... I don't use XML::Twig myself) seems mirod did not think it's necessary.

      Yes, I agree that other thread is a bit hard to find.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.

        Well, the XML::Twig object is an old fashion hashref, and I have no plan to change this, so you can always add your own fields to it. Or use a "hidden" attribute (one which names starts with '#') to attach private data to any element, including the root.

        A closure is the cleanest way to go though. It's not a trick, it's just a common idiom.

        BTW, a google search on "XML::Twig passing data to handlers" (or using "arguments" instead of data) returns plenty of answers to that question.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://996592]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-23 09:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found