my %citystate; my %citycountry; my %country; my %airportCode; my %geonameid; if ($line =~ /.*Cannot find valid (destination) for type:(.*)=(.*)/) { my $type = $2; my $key = $3; if ($type =~ /citystate/) { $citystate{$key} = ""; } elsif ($type =~ /citycountry/) { $citycountry{$key} = ""; } elsif ($type =~ /country/) { $country{$key} = ""; } elsif ($type =~ /airportCode/) { $airportCode{$key} = ""; } elsif ($type =~ /geonameid/) { $geonameid{$key} = ""; } } for my $key ( keys %citystate ) { $fhdest -> print("

$key

"); } for my $key ( keys %citycountry ) { $fhdest -> print("

$key

"); } for my $key ( keys %airportCode ) { $fhdest -> print("

$key

"); }