On Wednesday 01 May 2002 2:26 pm, Bob Showalter wrote:
[snip]
> > {$array{$_}++} foreach @array;
>
> They are the same as far as the effect on %array. But you
> shouldn't use map() in a void context, as it constructs a
> result list which is then thrown away. So your iterative
> approach is better.
>
> Better still IMO is:
>
>    { my %seen; @array = grep { !$seen{$_}++ } @array; }

So, this foreach's @array, passing $_ through grep, which looks to see if 
it's contained in %seen, returning $_ if it isn't - i.e. on first seeing $_.  
it performs the actions $seen{$_}++ in the process.

right?
-- 
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