my %labels; foreach (my $z = 0; $z < scalar @{$hash_ref -> {supported_countries}}; $z ++) { $labels{$hash_ref -> {supported_countries} -> [$z]} = $hash_ref -> {country_names} -> [$z]; }