Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: XML::Twig - Twig Handler question

by mirod (Canon)
on Dec 15, 2003 at 14:05 UTC ( [id://314822]=note: print w/replies, xml ) Need Help??


in reply to XML::Twig - Twig Handler question

The handler is always called with just 2 parameters, the twig and the element. So if you want to add new elements, you have to use a closure: make the handler an anonymous subroutine. It can then use lexicals in scope when it is defined. It might sound complicated, but practically it is very simpleand natural:

my $t= XML::Twig->new( twig_handlers => { 'JOB_SECTIONS/SWITCH' => sub { $self->_up +load_job( @_) } },...

You can get much better explanations about what's going on there in Simon Cozens Achieving Closure.

Replies are listed 'Best First'.
Re: Re: XML::Twig - Twig Handler question
by set_uk (Pilgrim) on Dec 15, 2003 at 16:01 UTC
    That did the trick. Thanks.
    Really good module - made my life a lot easier - thanks

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found