# there are actually lots more institutions than this, # but this gets the point across if (!defined $institution) { $institution_table{"unaffiliated"} ++; } elsif ($institution =~ /^$hospital1$/i) { $institution_table{$hospital1} ++; } elsif ($institution =~ /^$hospital2$/i) { $institution_table{$hospital2} ++; } else { $institution_table{"other"} ++; } foreach (sort keys %institution_table) { $institution_table{$_}{"fortyfive_fifty"} ++ if (45 < $age <= 50); $institution_table{$_}{"fifty_fiftyfive"} ++ if (50 < $age <= 55); $institution_table{$_}{"fiftyfive_sixty"} ++ if (55 < $age <= 60); #...and so on up through the 85-90 age bracket }