while (($ref, $val) = get_pair()) { my %thisrecord = { ref => $ref, val => $val }; $record{$ref} = \%thisrecord; }