use strict; use warnings; my $info = test(); for my $name (sort keys %$info) { printf "%-10s %s\n", "$name:", $info->{$name}; } sub test { my (@names_all, @email_all); my @names = qw(Joe mary ann pete amy jerry Joe ann); my @email = qw(joe@test.com mary@test.com ann@nowhere.com pete@here.com amy@ok.com jerry@b.com joe@test.com ann@nowhere.com); my %emails; @emails{@names_all} = @email_all; @emails{@names} = @email; return \%emails; }