I am using XML::Twig to convert XML from one form to another.
I want to be able to use XML::Twig as part of a larger package where the subs reference one another via $self->subroutinename syntax as self contains allsorts of necessary config data.
I have no issue using XML::Twig except for one thing.
The doc states setting up a callback to a twig handler is defined as :-
my $twig= new XML::Twig(
TwigHandlers => # player will be call
+ed
{ player => \&player } # when each player el
+ement
); # has been parsed
I want to be able to set up a callback as :-
my $t= XML::Twig->new( twig_handlers =>
{ 'JOB_SECTIONS/SWITCH' => $self->_upload_j
+ob()},
pretty_print => 'indented'
)->parsefile($InFileName);
However when I do this it breaks the twig handler as the twig and element are not passed into the sub. The sub is fired though.
I could but would prefer not to have to code around this.
Any ideas? How can I reference self if it isn't passed into the sub?
Simon
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.