Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
That would be 2 or more times right? Once ++$seen{$_} == 2 is true, you are immediatelly copying $_ to @doubles. So if it appeared a third time, you couldn't magically remove it again. Your code would be clearer if you used >= to emphasize that. The following would probably do if you only wanted entries with exactly 2 occurences:
But it is not pretty, or obvious. The first grep counts all occurences and only passes the first found entry to the next grep which will check to see how many were actually found. There must be a better way!- Cees In reply to Re: Re: Re: Perl Idioms Explained - keys %{{map{$_=>1}@list}}
by cees
|
|