|
You can pass parameters by using a closure:
my $p=1;
my $twig= XML::Twig->new( twig_handlers => { foo => sub { foo( @_, $p); } })
->parsefile( "my.xml");
sub foo
{ my( $twig, $elt, $param)= @_;
...
}
Simon Cozen's Achieving Closure has a good description of what a closure is, including an example with XML::Twig. |