Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Re: Array Comparison

by Roy Johnson (Monsignor)
on Dec 22, 2003 at 18:37 UTC ( [id://316440]=note: print w/replies, xml ) Need Help??


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}};

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://316440]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-16 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found