in reply to Get All Duplicated Elements in an Array (Once, without shifting)
Maybe I'm missing something, but...
for(@in){ $hash{$_}++; } foreach my $key (keys %hash){ print "$key is lonely\n" if ($hash{$key} == 1); print "$key has friends\n" if ($hash{$key} != 1); }
thor
Update: changed %hash{$_}++ to $hash{$_}++ to make it correct.
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Re: Get All Duplicated Elements in an Array (Once, without shifting)
by merlyn (Sage) on Oct 15, 2002 at 01:14 UTC | |
by demerphq (Chancellor) on Oct 18, 2002 at 17:35 UTC | |
by dragonchild (Archbishop) on Apr 18, 2005 at 14:20 UTC | |
by graq (Curate) on Aug 11, 2006 at 13:43 UTC | |
|
In Section
Seekers of Perl Wisdom