Buckaroo Buddha has asked for the wisdom of the Perl Monks concerning the following question:
How do I do this in one line?
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...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
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
to create that hash on its first pass and on subsequent iterations of "while" use the same hash?&build_list(\%hash1,\%hash2);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: defining a HASH table by reference and using it in a sub function
by btrott (Parson) on May 19, 2000 at 01:50 UTC | |
Re: defining a HASH table by reference and using it in a sub function
by Russ (Deacon) on May 19, 2000 at 01:54 UTC |
Back to
Seekers of Perl Wisdom