Help for this page

Select Code to Download


  1. or download this
      DB<1> %a = (a => 1, b =>2, c => 3); %b = (b =>2, c => 1, d => 4)
      DB<2> $seen{$_}++ for (keys(%a), keys(%b))
      DB<3> x grep { $seen{$_} > 1 } keys(%seen)
    0  'c'
    1  'b'
    
  2. or download this
      DB<1> use List::Util qw{first}
      DB<2> %a = (a => 1, b =>2, c => 3); %b = (b =>2, c => 1, d => 4)
      DB<3> x first { ++$seen{$_} > 1 } (keys(%a), keys(%b))
    0  'c'