Please put <CODE> </CODE> tags around your code, it keeps it from wrapping messily,and renders Perl code HTML-safe.
###### else { print EBSDET parser ($bai{$ocab}{d16}[$1]{text_full}, (27- $bai{$ocab}{d16}[$1]{n2_offset}), 27,"\;",12); } ######
Okay, let's take this apart piece by piece. First there's a call to print Easy enough. The EBDSET is (presumably) an open filehandle, which means that print will send the rest of the line to that file. parser appears to be a subroutine call. Somewhere else in the program you should find sub parser that defines what parser does. In particular, the arguments that are passed to parser (inside the ()'s) will show up in the @_ array.

Next, we have the arguments to parser(). There are 5.

  1. $bai{$ocab}{d16}[$1]{text_full}
  2. 27 - $bai{$ocab}{d16}[$1]{n2_offset}
  3. 27
  4. "\;"
  5. 12
I think the trouble for you is the syntax found in #1 and #2. These are references, documented in perlref. Basically this is $bai{$ocab}->{d16}->[$1]->{text_full}, or more verbosely: $bai is a hash. The value stored at $bai{$ocab} is a reference to a hash. The value stored at key d16 of that hash is an array reference. The value stored at index $1 of that array is a hash reference. You are ultimately getting the value stored at key text_full of that array.

references are a bit of an advanced concept, but basically they are a way to nest data structures (lists of lists, lists of hashes, etc)
Update:Adam correctly points out that I'm short selling references (see below). Read the replies for more in depth coverage, but this explanation is enough for this question.

Next:

push(@{ $pay[($#pay + 1)] }, $pay_aba, $pay_acct);
@pay is an array. $#pay is the index of the last element of that array (Note that since arrays normally start at 0, "index of the last element" and "size" are not the same. $#pay+1 is normally the size of the array.

I suspect the problem here is again, references. Like I said, see perlref, but Here's the basics:

If $foo is a reference to an array (All references are scalar values), the way to deal with the array that $foo refers to is @{$foo} So here, we see that $pay[($#pay+1)] is being treated as an array reference. I don't imagine that's good practice, as $#pay+1 should not exist on @pay (It's one past the last index). A better way to write this would be:

push @pay, [$pay_aba, $pay_acct];
This creates a reference to an anonymous array (consisting of $pay_aba and $pay_acct), and pushes it onto the end of @pay.

Hope this helps, and if you're a Perl newbie, here's the tip that everyone will tell you: Have your programs use strict;, and run perl with the -w flag. You'll get sick of error messages, but you'll quickly write better code, and better understand what's going on.


In reply to Re: Is this a hash? or what? by swiftone
in thread Is this a hash? or what? by Zo

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.