I may be missing the point here...

Since you seem to be using global variables anyway, you don't need to even return anything from build_list.

You are passing in references to hashes. Those hashes are being modified by build_list. Your assignment to the hashes from the return value of build_list is redundant. They are already modified when build_list returns. Just use %RECORDxRI_count and %EACH_RECORD.

I assume you are doing more in build_list and the <DATA> loop than you actually posted...

Here is some condensed code (since you expressed interest in minimizing lines of code):

my %RECORDxRI_count; my %EACH_RECORD; sub build_list { my( $RECORD, $RI, $RECORDxRI, $RECORDxRI_count_REF, $EACH_RECORD_REF + ) = @_; $RECORDxRI_count_REF->{$RECORDxRI}++; $EACH_RECORD_REF->{$RECORD} = ''; } while <DATA> { my( $Record54, $Record38 ) = (split /\t/)[54, 38]; my $RECORD = (split /{/, $Record54)[0]; $RECORDxRI = $RECORD . ',' . $Record38; build_list( $RECORD, $RI, $RECORDxRI, \%$RECORDxRI_count, \%EACH_REC +ORD ); }
Notes:

Hope this is helpful...
Russ


In reply to Re: defining a HASH table by reference and using it in a sub function by Russ
in thread defining a HASH table by reference and using it in a sub function by Buckaroo Buddha

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.