#!/usr/bin/perl -wl use strict; my @many = (1,4,2,3,2,1); my %count; $count{$_}++ for @many; my @once = grep {$count{$_} == 1} @many; print "@many"; print "@once"; __END__ Prints: 1 2 3 2 1 4 3
--
John.
In reply to Re: finding unique elements in an array
by jmcnamara
in thread finding unique elements in an array
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |