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 |