my %parent = ( europe => [qw| london moscow |], asia => [qw| tokyo seoul |], africa => [qw| cario algiers |], ); #### sub fallover { my ($hash, $failure) = @_; my $list = delete($hash->{$failure}) or return; my @targets = keys %$hash; my $i = 0; while (@$list) { my $city = shift @$list; push @{$hash->{$targets[$i++]}}, $city; $i %= @targets; } }