Iterate through a hashref using XML::Simple (real post)
Hi I'm struggling with the use of XML::Simple so was hoping that someone might be able to help me. I'm kind of new to perl, especially when dealing with hash references. I would like to iterate through the hash that is created by the XMLIn function. Here is my code: use Env qw(GMNHOME GMNSQLSRVR GVHOME); use XML::Simple; use Data::Dumper; $ref = XMLin("$HOME/tmp/foo.xml"); $FirstReject = $ref->{RejectRecord}->[0]->{Reason}; print "First Reject is $FirstReject \n"; The a sample of the contents of the XML file is found below: Notice that I've hardcode the first reference to Rejected Records by using [0]. Well I need to know how of these there are in the hashref $ref so I can iterate through. Any help would be much appreciated. Thanks in advance. Ray XML File foo.xml FAILURE: Attempt to add Customer has failed LarryBoy 1234 FAILURE: Attempt to add Customer has failed JimBob 1234 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Iterate through a hashref using XML::Simple
Hi, I'm struggling with the use of the XML::Simple package and was hoping to get some help. I'm kind of new to perl, especially dealing with hash references. I would like to be able to iterate through a hashref that is built using XMLin. Here is the code: -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/