Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Grepping on array

by herveus (Prior)
on May 19, 2004 at 13:08 UTC ( [id://354592]=note: print w/replies, xml ) Need Help??


in reply to Grepping on array

Howdy!

my %first = map { $_ => 1 } @arr2; @result = grep !exists $first{$_}, @arr1;

%first is a hash whose keys are the distinct values in @arr2. The grep returns a list of the values in @arr1 that don't exist in %first, thus eliminating values in @arr2.

yours,
Michael

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-23 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found