Seem to be having an issue in trying to walk hash of hashs. It seemed to be working but now not working. I uninstalled perl and installed again (activestate 5.18 64bit)

Just updated to perl 5.20.2.2002 64bit - still same result.

#!perl use XML::Simple; use Data::Dumper; my $xmlSimple = new XML::Simple(KeepRoot => 1); my $professionsXML = $xmlSimple->XMLin("data/misc/test.xml"); print Dumper($professionsXML); print qq(0.1: $professionsXML{'profs'}{'name'}\n); print qq(0.2: $professionsXML{'profs'}{'profcats'}{'name'}\n); foreach my $key (keys %{$professionsXML}) { print qq(1: $key\n); foreach my $key2 (keys %{$professionsXML{$key}}) { print qq(2: $key2\n); foreach my $key3 (keys %{$professionsXML{$key}{$key2}}) { print qq(3: $key3\n); foreach my $key4 (keys %{$professionsXML{$key}{$key2}{$key +3}}) { print qq(4: $key4\n); } } } } exit(0);

XML Source

<profs> <name>prof</name> <profcats> <name>cat</name> <profcatgroups> <name>group</name> <profcatgroup> <name>prof1</name> </profcatgroup> </profcatgroups> </profcats> </profs>

Output

C:\Utils\Apache\Apache-httpd-2.2\cgi-bin>perl generate03.pl $VAR1 = { 'profs' => { 'profcats' => { 'profcatgroups' => { 'name' => 'group +', 'profcatgroup' = +> { + 'name' => 'prof1' +} }, 'name' => 'cat' }, 'name' => 'prof' } }; 0.1: 0.2: 1: profs 2: profcats C:\Utils\Apache\Apache-httpd-2.2\cgi-bin>

As you can see from output, it I can't seem to manually walk tree, and in using loops to walk try it seems to get hungup after profcats.


In reply to Walking Hash of hash issue? by Syrkres

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.