in reply to Re: Help with removing duplicates in array
in thread Help with removing duplicates in array

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)
  • Comment on Re^2: Help with removing duplicates in array

Replies are listed 'Best First'.
Re^3: Help with removing duplicates in array
by hippo (Archbishop) on Mar 27, 2015 at 13:44 UTC

    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));