GuiPerl:

If you use Dumper to print out the data structure, you can look at the structure to see what to do. For example:

$VAR1 = ( # top level look at next item to see if array + or hash FOO=>{ # Key: top level is hash. { means next is ha +sh too BAR=>{ # another hash BAZ=>[ # square bracket starts an array { BIM=>1 }, # slot 0 contains a hash { BIM=>5 }, # slot 1 also contains a hash 'GEORGE', # slot 2 holds a string [3,6,9] # slot 3 holds an array }, }, }, FOE=>[ # FOE is key for an array ['a','b','c'], # slot 0 holds another array {FUM=>'FIE'}, # slot 1 holds a hash ], ); say $H{FOO}{BAR}{BAZ}[0]{BIM}; # should show 1 say $H{FOO}{BAR}{BAZ}[2]; # should show GEORGE say $H{FOO}{BAR}{BAZ}[3][1]; # should show 6 say $H{FOE}[0][2]; # should show c say $H{FOE}[1]{FUM}; # should show FIE

So look at your Dumper output, and look at the characters used to separate the levels. You'll want to use the same characters to get to the data you want. Does that help clear things up?

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re^7: Counting Problem by roboticus
in thread Counting Problem by GuiPerl

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.