Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: intersecting two hashes

by RichardK (Parson)
on Jan 26, 2016 at 08:51 UTC ( [id://1153652]=note: print w/replies, xml ) Need Help??


in reply to Re: intersecting two hashes
in thread intersecting two hashes

Alternatively, you could find just the keys shared by both hashes using grep

use v5.22; use warnings; my %hash1 = ( a => 1, b => 2, c => 3, ); my %hash2 = ( b => 4, e => 5, f => 6, c => 7, ); my @results = grep { exists $hash2{$_} } keys %hash1; say join ',',@results; #b,c

Log In?
Username:
Password:

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

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

    No recent polls found