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; } #### Unique: jerry email: jerry@b.com Unique: pete email: pete@here.com Dups: Joe email: joe@test.com email: joe@test.com Dups: John email: John@test.com email: John@ok.com Unique: amy email: amy@ok.com Dups: ann email: ann@nowhere.com email: ann@nowhere.com Unique: mary email: mary@test.com