Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: intersecting two hashes

by RichardK (Parson)
on Jan 26, 2016 at 08:51 UTC ( #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
Node Status?
node history
Node Type: note [id://1153652]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2018-12-15 17:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many stories does it take before you've heard them all?







    Results (70 votes). Check out past polls.

    Notices?