use strict; use warnings; my $info = test(); printing($info); sub printing { my ($args) = @_; foreach my $name ( keys %{$args} ) { # tell the number of emails attached to a person my $count = scalar @{ $args->{$name} }; # if more than one email is attached to a person # that individual is not Unique $count == 1 ? print "Unique: ", $name, " email: ", @{ $args->{$name} }, $/ : print "Dups: ", $name, map { " email: $_$/" } @{ $args->{$name} }; } } sub test { my @names = qw(Joe mary ann pete amy jerry Joe ann John John ); 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 John@test.com John@ok.com); my %emails; foreach my $name (@names) { push @{ $emails{$name} }, shift @email; } return \%emails; }