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 } );