foreach my $friendref ( @{ $VAR1->{ut_response}[0]{friend_list}{friend +} } ) { print "Hi $friendref->{user}\n"; }
meets your requirements, but it will benefit you in the long run to learn about references. See perlreftut, perldsc, and perlref for starters. Our Tutorials page has a section entitled Data Types and Variables, which will also help.

Update: Complex data structures can be tricky to wrap your head around at first. It might be easier to understand by breaking the solution into steps. Here is one way you could think about the goo in the foreach line, above:

@{ # the array referenced by: $VAR1-> # dereference $VAR {ut_response} # then get the value of the hash key 'ut_respo +nse' [0] # then get the 0th element of that array {friend_list} # then get the value of the hash key 'friend_l +ist' {friend} # then get the value of the hash key 'friend' }

Each one of those steps could be performed individually using temporary variables:

my $ut_aref = $VAR1->{ut_response}; my $href = $ut_aref->[0]; my $flist_href = $href->{friend_list}; my $f_aref = $flist_href->{friend}; foreach my $friendref ( @{ $f_aref } ) ...


In reply to Re: Seeking some noob wisdom with XML::Simple by bobf
in thread Seeking some noob wisdom with XML::Simple by downer

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.