How do I do this in one line?
sub build_list {
($RECORD,$RI,$RECORDxRI,$RECORDxRI_count_REF,$EACH_RECORD_REF) = @
+_;
%RECORDxRI_count = %$RECORDxRI_count_REF;
%EACH_RECORD = %$EACH_RECORD_REF;
$RECORDxRI_count{$RECORDxRI}++;
$EACH_RECORD{$RECORD} = '';
return(\%RECORDxRI_count,\%EACH_RECORD);
}
while <DATA> {
@record = split('\t',$_);
$RI = @record[38];
($RECORD,$junk) = split('{',@record[54]);
$RECORDxRI = $RECORD . ',' . $RI;
($RECORDxRI_count_REF,$EACH_RECORD_REF) = &build_list($RECORD,$RI,
+$RECORDxRI,\%$RECORDxRI_count,\%EACH_RECORD);
%RECORDxRI_count = %RECORDxRI_count_REF;
%EACH_RECORD = %$EACH_RECORD_REF;
# NOTE: I have to dereference both hashes
# on every iteration of the while loop
} # end while data
OK ... I understand that ONE line is a little overzealous,
but I'm actually interested in making the function call
to &build_list in one line...
Is there a way to get a full hash without
dereferencing the hashes I pass to the routine on
every iteration of this loop?
Could I get
&build_list(\%hash1,\%hash2);
to create that hash on its first pass and on
subsequent iterations of "while" use the same hash?
-
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 How to display code and escape characters
are good places to start.