in reply to Re: Array Comparison
in thread Array Comparison

I think that should be
my @cleaned = grep { not exists $exclude{$_} } @words;
Grep returns the original value for every element for which the expression returns true. Your ternary operator would be useful in map, but not here.

The PerlMonk tr/// Advocate

Replies are listed 'Best First'.
Re: Re: Re: Array Comparison
by mcogan1966 (Monk) on Dec 22, 2003 at 18:54 UTC
    Excellent, this works much faster.

    Now, if I can just sort and make the list with just unique entries, I'm all set. Thanks.

      my @uniq = sort keys %{{map {$_ => 1} @cleaned}};
      or you could combine two statements in one (not recommended though :-) ...
      my @uniq = sort keys %{{map {$_ => 1} grep{not exists $exclude{$_}}@words}};