ixl has asked for the wisdom of the Perl Monks concerning the following question:
When I want to use it, it only works for the first :Package Report; sub new() { my $self = {}; bless($self); [...] $self->{tree} = (); my $p = new XML::Parser( Handlers => { Start => \&handle_start, Default => \&handle_char, } ); $p->parsefile($my_file); sub handle_char() { # ... update $self->{tree} } sub handle_start() { # ... update $self->{tree} print Dumper \$self->{tree}; #dumper 1 } print Dumper \$self->{tree}; #dumper 2 return $self; }
I see that the second object uses the same tree of the first object.my $r = new Report('file1'); #all is good $r = new Report('file2'); # Dumper1 shows the first tree updated with the data of the second # and dumper2 shows nothing (undef)
Thanks for your wisdom.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Objects, callbacks and XML::Parser
by Fletch (Bishop) on Dec 08, 2006 at 17:45 UTC | |
by ixl (Initiate) on Dec 11, 2006 at 09:23 UTC | |
|
Re: Objects, callbacks and XML::Parser
by Joost (Canon) on Dec 09, 2006 at 00:21 UTC |