foreach (sort keys %institution_table) { $institution_table{$_}{"fortyfive_fifty"} ++ if (45 < $age and $age <= 50); $institution_table{$_}{"fifty_fiftyfive"} ++ if (50 < $age and $age <= 55); $institution_table{$_}{"fiftyfive_sixty"} ++ if (55 < $age and $age <= 60); #...and so on up through the 85-90 age bracket }