Hi (again !)
I posted a question yesterday just for info on hashrefs which I have read and it makes sense. Putting this into proactive though has now toally confused me !
I have an XML file sucked into a hash via XML::Simple. That's OK. I can see the data using Data::Dumper.
I seem to have a Hash of Arrays, and those Arrays contain another hash.
All I am trying to do is get to the data but every route I take I am getting myself into more confusion.
I have copied a chunk of the code in bwloe so you can tell me what I am missing (and laugh a bit at the same time at a novice !! lol)
-
use XML::Simple;
-
my $xml_hash = XMLin('concorde.xml');
-
# use Data::Dumper;
-
# print Dumper($xml_hash);
-
-
print "first hash : $xml_hash\n";
-
-
for my $key (keys %{$xml_hash}) {
-
print "$key => ${$xml_hash}{$key}\n";
-
#output from above is a single key of "ORDER"
-
}
-
-
print "test0: ${$xml_hash}{ORDER}[0]\n";
-
print "test1: ${$xml_hash}{ORDER}[1]\n";
-
-
my $next_hash = "${$xml_hash}{ORDER}[0]";
-
print "next hash : $next_hash \n";
-
for my $key (keys %{$next_hash}) {
-
print "$key => ${$next_hash}{$key}\n";
-
}
-
OK.. the output of the above is:
-
first hash : HASH(0x304867a8)
-
ORDER => ARRAY(0x304b00d0)
-
test0: HASH(0x30486c1c)
-
test1: HASH(0x30486d54)
-
next hash : HASH(0x30486c1c)
-
Something I have done is clearly wrong/stupid etc.
Help !! Once I get one working I'll be fine !
Keith