use List::Util 'first'; if(first{exists $hashRef2->{$_}} keys %$hashRef1 ) # }