my $sum4 = 0; while ( my ($k, $v) = each %$hashref ) { $sum4 += length($k) + length($v) }