# Define them as hash references. my $RECORDxRI_count_REF = {}; my $EACH_RECORD_REF = {}; while () { .... # Call build list--now you don't need to # take references to the hashes, because they're # already references build_list( $RECORD, $RI, $RECORDxRI, $RECORDxRI_count_REF, $EACH_RECORD_REF ); .... } sub build_list { my( $RECORD, $RI, $RECORDxRI, $RECORDxRI_count_REF, $EACH_RECORD_REF ) = @_; # These are hash references. To access them, # you *don't* need to assign them to hashes. # Just use the -> operator, which automatically # dereferences them. $RECORDxRI_count->{$RECORDxRI}++; $EACH_RECORD->{$RECORD} = ''; }