$practice = {}; foreach $patient(@{$self->{patient_details}}) { push @{ $practice->{ $patient->{suregery_id} } }, $patient; }