Hi,
I'm having a problem referencing/returning my hash arrays and thought I would ask here ... I've been stuck on this for 2 days already trying to read/understand perldocs etc.! pretty new to Perl so apologies if this is a super-n00b question.
I'm trying to pass an array of hash arrays to-and-from a sub.
E.g. : $F_SCORE$i{$co})where $i is the year counter, and $co is a company name string.

My basic code is this:

At end of sub:

    return (\@date, \@F_SCORE, \@F_SCORE_BOX, \@F_ROA, \@F_CFO, \@F_dROA, \@F_ACCRUAL, \@F_dLEVER, \@F_dLIQUID, \@F_EQOFFER, \@F_dTURN, \@F_dMARGIN);

then in main:

my ($date_ref, $F_SCORE_ref, $F_SCORE_BOX_ref, $F_ROA_ref, $F_CFO_ +ref, $F_dROA_ref, $F_ACCRUAL_ref, $F_dLEVER_ref, $F_dLIQUID_ref, $F_E +QOFFER_ref, $F_dTURN_ref, $F_dMARGIN_ref) = piotroski (\@balancesheet +s, \@cashflows, \@pnl, \@cdata, $co_name, $yahoo_isin, $co_exchange, +$statement_cur, $px_cur); my (@date, @F_SCORE, @F_SCORE_BOX, @F_ROA, @F_CFO, @F_dROA, @F_ACC +RUAL, @F_dLEVER, @F_dLIQUID, @F_EQOFFER, @F_dTURN, @F_dMARGIN) = (@$d +ate_ref, @$F_SCORE_ref, @$F_SCORE_BOX_ref, @$F_ROA_ref, @$F_CFO_ref, +@$F_dROA_ref, @$F_ACCRUAL_ref, @$F_dLEVER_ref, @$F_dLIQUID_ref, @$F_E +QOFFER_ref, @$F_dTURN_ref, @$F_dMARGIN_ref); print "/$date[0]{$co_name}\t$date[1]{$co_name}\t$date[2]{$co_name} +\t$date[3]{$co_name}\t$date[4]{$co_name}\n"; print "/$F_SCORE[0]{$co_name}\t/$F_SCORE[1]{$co_name}\t/$F_SCORE[2 +]{$co_name}\t/$F_SCORE[3]{$co_name}\t/$F_SCORE[4]{$co_name}\n";


Confusingly for me, $date prints each element just fine, whereas none of the others seem to contain any data (that I have find). In the sub itself, they work fine and I can dump F_Score (and other) values to the screen.

Kinda stumped and thought some kind soul here might have an idea! (I'm sure there is a better way to do this too ... I'm all ears!)

Thanks,

Carl

In reply to Referencing/returning array of hashes from sub by PoGGiE

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.