while (my $d = $ks_sth->fetchrow_hashref()){ $KP->{$d->{k}}{$d->{v}}++; }