Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: How to return two and more values by parsing XML with XML::Rules?

by Jenda (Abbot)
on Nov 08, 2012 at 07:56 UTC ( #1002830=note: print w/ replies, xml ) Need Help??


in reply to Re: How to return two and more values by parsing XML with XML::Rules?
in thread How to return two and more values by parsing XML with XML::Rules?

Or, if you really are against using globals, use the $parser->{pad} to hold your data:

my @rules = ( AM_Key => sub { push @{$_[4]->{pad}{am_keys}}, $_[1]{_content}; retu +rn }, LK_Key => sub { push @{$_[4]->{pad}{lk_keys}}, $_[1]{_content}; retu +rn }, Outpatient_Services => sub { LK_Keys => $_[4]->{pad}{lk_keys}, AM_Ke +ys => $_[4]->{pad}{am_keys}}, _default => undef, ); my $xr = XML::Rules->new( rules => \@rules );

With this $xr->parse() returns a HoA containing the array of the AM_Keys and the array of LK_Keys.

Jenda
Enoch was right!
Enjoy the last years of Rome.


Comment on Re^2: How to return two and more values by parsing XML with XML::Rules?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2015-07-03 16:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (54 votes), past polls