Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: best practice when using XML::Parser and strict.

by moot (Chaplain)
on Feb 28, 2005 at 12:28 UTC ( [id://435038]=note: print w/replies, xml ) Need Help??


in reply to best practice when using XML::Parser and strict.

Have you thought about using a class, and setting up your handlers as closures? Something like..
package MyHandler; sub new { bless { indent => 0 }, shift } sub handle_start { my ($self, $p, $el, %atts) = @_; # use $self->{indent} here ... } sub handle_end { my ($self) = @_; # likewise here ... } 1; ... use XML::Parser; use strict; sub parse_stuff { my $handler = MyHandler->new(); my $parser = new XML::Parser(Handlers => { Start => sub { $handler-> +handle_start(@_) }, End => sub { $handler->handle_end(@_)}); $parser->parsefile('/tmp/ra.xml'); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-16 05:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found