sub make_lookup { my %hash = map { my $hash = $_; join(':', map { $hash->{$_} || "" } sort(keys(%{$_})) ) => $_ } @_; return \%hash; } my $lookup = make_lookup(@{GetQueryTable('all_records_for_report', 138)});