On Sat, 19 Jan 2013 19:43:15 -0800
Jim Gibson <[email protected]> wrote:
> Use a hash to count the number of times each item appears in the
> array:
>
> my %counts;
> $counts{$_}++ for @my_array;
>
> Then, extract the keys the have a count of 1:
>
> my @new_array = map { $counts{$_} == 1 } keys %counts;
Yep, that's how I'd do it, but you meant grep, not map :)
--
David Precious ("bigpresh") <[email protected]>
http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan www.preshweb.co.uk/github
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/