Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Common hash keys

by radiantmatrix (Parson)
on Jun 09, 2008 at 20:46 UTC ( [id://691095]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    %a = ( one=>1, two=>2, three=> 3 );
    %b = ( two=>'two', three=>'three', four=>'four');
    
  2. or download this
    if (exists $a{one}) { print "\%a has 'one' for a key" }
    
  3. or download this
    print join(",", keys %a); # prints "one,two,three"
    
  4. or download this
    my @common_keys;
    foreach my $key (keys %a) {
    ...
          push @common_keys, $key;
       }
    }
    
  5. or download this
    my @common_keys = grep { exists $b{$_} } keys(%a);
    
  6. or download this
    $x = \%a;
    $y = \%b;
    
  7. or download this
    my @common_keys = grep { exists $y->{$_} } keys( %{ $x } );
    

Log In?
Username:
Password:

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

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

    No recent polls found