You're trying to pass an object function call (
$self->handle_end()) as an object reference. The code you've got will attempt to dereference $self as a code reference, which it isn't.
Instead, you need to create an anonymous subroutine that will pass the correct value of $self along to XML::Parser. Anonymous subroutines are neat, if easy to abuse.
The important thing about anonymous subroutines, also known as closures, is that they hang onto the value of any lexical variables inside it. Read perlman:perlsub for more about closures. So, if I created an anonymous subroutine inside a hash, like so:
my $self = Foo->new();
my $mysub = sub { $self->increment() };
...and then later on used it:
$mysub->();
Then the correct value of $self would be have increment() called on it.
So, in order to fix your problem, you need to create closures around your method calls. I'll leave the rest to you. :)
stephen
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.