sub uniq { #and this to handle the duplicated emails return keys %{ { map { $_ => 1 } @_ } }; } say join ' ', uniq(qw( ABC DEF GHI JKL ABC DEF ABC )); #### GHI DEF ABC JKL #### my $removed = @findemails - @filtered;