Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Re: Removal of duplicated element in array.

by moritz (Cardinal)
on May 06, 2013 at 14:01 UTC ( #1032297=note: print w/replies, xml ) Need Help??

in reply to Removal of duplicated element in array.

How exactly does it not work? What exactly is in $1? What output do you expect? Are you aware that the code as-is splits on newline characters, which means that "duplicate items" actually mean "duplicate lines"?

If you want to deduplicate a list, I recommend List::MoreUtils::uniq.

Replies are listed 'Best First'.
Re^2: Removal of duplicated element in array.
by tty1x (Novice) on May 06, 2013 at 14:10 UTC
    $1 is essentially a list of email addresses.

      my %seen = map {$_=>1} <DATA>; use Data::Dumper; print Dumper \%seen; __DATA__
      If you care about the order of display then you can use this:
        print join "\n", sort{$a cmp $b} keys %seen;

      *Note: That was based on the assumption, that the original ORDER of data was inconsequential.
      Limbic~Region Thanks for pointing that out.

      If you tell me, I'll forget.
      If you show me, I'll remember.
      if you involve me, I'll understand.
      --- Author unknown to me
        If you care about the order of display then you can use this

        The code in the OP looked like it was preserving the original order - what you have posted loses that ordering and sorting ASCIIbetically after the fact isn't going to re-instate it unless it coincidentally was sorted that way in the first place.

        Cheers - L~R

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1032297]
[Corion]: Yay, invitation for a team-building workshop, with a team of 100 people :-/
[Eily]: marto after an additional read I started to see the light actually. And choroba's link was helpful as well :)
[Corion]: I'll send my colleague who doesn't yet know the people there, and I'll do production duty instead.
[GotToBTru]: ugh. Thanks Corion
[shmem]: meh. setting up a SIG{__DIE__} before loading Net::SSLeay still triggers Can't locate object method "tid" via package "threads" at /usr/share/perl/5. 20/

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2017-07-26 15:08 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (396 votes). Check out past polls.