Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2018-07-19 23:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (421 votes). Check out past polls.

    Notices?