while (my $ref2 = $sth2->fetchrow_hashref()) { while (my ($k, $v) = each %$ref2) { $ref2->{$k} = '' if $v == undef; } }