Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2022-08-11 02:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?