my $count = keys %{ $testHash{$year} } #### my $first = 1; while (...) { print ',' unless $first; undef $first; print "..."; # print the sentence }