# SQL #SELECT DISTINCT date FROM hit WHERE location_id = $loc_id # will get a list back in the form 'YYYY-MM-DD' my %months; while (my $row = $sth->fetchrow) { my ($year, $month, $day) = split '-', $row; push @{$months{"$month-$year"}}, $day; } # cheap print routine to illustrate access to the hash foreach my $month (keys %months) { print "For the month of $month, we have events on the following days :\n"; print "$_ " foreach (@{$months{$month}}); print "\n"; }