note
Anonymous Monk
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.
<p>
Witness:
<p>
<pre>
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) = @_;
...
}
</pre>
62782
62789
14