On Wednesday 01 May 2002 1:43 pm, fliptop wrote:
> Andrew Rosolino wrote:
> > Say I have an array that contains!
> >
> > @array = qw( cool cool dog dog dog );
> >
> > Now I want to sum that up, so that the array only has
> > 1 COOL and 1 DOG, so it would contain!
> >
> > @array = qw( cool dog );
>
> my %array;
>
> map { $array{$_}++ } @array;

What's the difference between the above, and the below, and why is one better 
than the other?

{$array{$_}++} foreach @array;

>
> my @unique = keys %array;
>
> there are several examples in the perl cookbook that demonstrate other
> methods for finding unions, intersections, etc.

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to