On Sat, 19 Jan 2013 19:43:15 -0800
Jim Gibson <jimsgib...@gmail.com> 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") <dav...@preshweb.co.uk>
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: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to