in reply to Help with removing duplicates in array

The uniq subroutine works correctly for strings, as you can easily verify:
sub uniq { #and this to handle the duplicated emails return keys %{ { map { $_ => 1 } @_ } }; } say join ' ', uniq(qw( ABC DEF GHI JKL ABC DEF ABC ));

Output:

GHI DEF ABC JKL

What do you mean by no "good results"? Note that $#filtered doesn't represent the number of duplicates removed, as the variable name suggests, but the number of unique e-mails minus 1. To get the number of removed ones, just use

my $removed = @findemails - @filtered;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Help with removing duplicates in array
by beanscake (Acolyte) on Mar 27, 2015 at 12:36 UTC
    ok thanks, i mean it's not removing duplicates as i intended it to work.. please if you can put this to a txt and run the script and see it's not removing these duplicates =>'aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net';
    The beginning of knowledge is the discovery of something we do not understand.
        Frank Herbert (1920 - 1986)

      Are you perhaps confusing a string with a list?

      use strict; use warnings; use feature 'say'; sub uniq { #and this to handle the duplicated emails return keys %{ { map { $_ => 1 } @_ } }; } my $string = 'aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net aaaa@jjj.net aaaa +@jjj.net aaaa@jjj.net aaaa@jjj.net'; say "string: ", join ' ', uniq($string); say "list: ", join ' ', uniq(split(/ /, $string));