my %valid_institutions = map { $_ => $_ } ( $hospital1, $hospital2, ); # ... my $key = $institution && ($valid_institution{lc($institution)} || "other") || "unaffiliated"; $institution_table{$key}{count}++;