Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Handler communication in XML::Twig

by mirod (Canon)
on Feb 12, 2004 at 17:41 UTC ( [id://328612]=note: print w/replies, xml ) Need Help??


in reply to Handler communication in XML::Twig

Indeed you can pass closures to new.

Have a look at Simon Cozens' Achieving Closure, which explains the process in great detail.

Basically you can do this:

my $t= XML::Twig->new( twig_handlers => { foo => sub { my_handler( @_, + @HOGS) } }); # ... sub my_handler { my( $t, $elt, @HOGS)= @_; # I would probably pass \@HOGC though

Replies are listed 'Best First'.
Re: Re: Handler communication in XML::Twig
by diotalevi (Canon) on Feb 12, 2004 at 17:45 UTC
    Do you use it that way or are you just confirming the possible? I'm after the method good X'T users use. I don't know how heavy the twig object and whether it would be preferred to retain the existing object.

      I use it a lot that way.

      I have never benchmarked the creation of the object itself, as I the type of code I write rarely parses a lot of files.

Log In?
Username:
Password:

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

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

    No recent polls found