Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Re: Re: Re: XML::Parser Tutorial

by Anonymous Monk
on Mar 14, 2001 at 15:41 UTC ( #64366=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: XML::Parser Tutorial
in thread XML::Parser Tutorial

The way to do this, without relying on the fact that the $p is a hashref, is to pass a closure as the handlers, and have an object that you created saved in the closure. This is how PerlSAX is implemented.

Witness:

my $handler = bless {}, "MyHandler";
my $p = XML::Parser->new(Handlers => {
   Start => sub { $handler->handle_start(@_) } 
});

package MyHandler;

sub handle_start {
  my ($handler, $p, $element, %attribs) = @_;
  ...
}

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://64366]
help
Chatterbox?
[marto]: "My solution is I just don’t use these tools anymore".
[ambrus]: Corion: Maybe I'm not explaining the situation clearly enough, maybe I'm just wrong and he's right and we can compute that data,
[ambrus]: but hopefully he just wants to think it through himself his way and understand why it's impossible rather than blindly accept my argument.
choroba quickly peeps in from a café
[1nickt]: Good morning Monks of the world!
[Corion]: ambrus: Yeah, hopefully it's that
[1nickt]: I am stumped, maybe someone brainy can clear my mind?

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (10)
As of 2017-12-12 13:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (332 votes). Check out past polls.

    Notices?