if($k_nuc eq $i_nuc){ $count->{$rel} ||= 0; $count->{$rel} += 1; }else{ $count->{$rel} ||= 0; $count->{$rel} += 0; } === possible change could be: ===== $count->{$rel} //= 0; ### probably not needed, see below if($k_nuc eq $i_nuc){ $count->{$rel}++; }