[kw-pm] unique

John Macdonald john at perlwolf.com
Wed Apr 19 13:36:03 PDT 2006


On Wed, Apr 19, 2006 at 11:48:28AM -0600, Dave Carr wrote:
> Hmmm...how about
> 
>  
> 
> %seen = ();
> 
> @uniq = grep(++$seen{$_} == 2, @items);

That works fine as long as the original (apparent) intent
of not creating an extra hash as big as the array was not
actually important.  (The extra space would rarely be important
in practice.)

-- 


More information about the kw-pm mailing list