in reply to Improve My Code...
chomp(@dates);
Only if they are pitted dates! (Otherwise, it's off to the dentist.)
Looks like you've got some Perl poetry there :)