my %countries = (); my $foo = "US:New York"; my ($country, $city) = (split /:/, $foo); push @{ $countries{$country} }, $city; #### foreach my $city (@{$countries{$country}}) { print "$city\n"; }