in reply to Finding Redundant values in arrays

TMTOWTDI:
my @test = qw(camel aplaca peguin aplaca monkey camel camel); my %temp; my @redundant = grep $temp{$_}++ == 1, @test; print "@redundant\n";
Update: Good catch, Wog. It works as expected now. I've corrected the line from:
#my @redundant = grep $temp{$_}++, @test;
I did test but didn't see the typo in converting to a qw(). Typing like 60 and missed the curve!

Weak rejoinder: though not the spec for this problem, it would be useful in some circumstances. ;-)

Replies are listed 'Best First'.
Re: Re: Finding Redundant values in arrays
by wog (Curate) on Jun 08, 2001 at 00:08 UTC
    Although this code works as given it is not a working solution. If we remove the " from the 'camel"', then it prints camel twice. (And it would do it more times if there were a fourth camel in the array, etc.)