#Loop 31 times foreach (1..31) { # Set date to $_ days in the past. my $date = time() - $_*24*60*60 my ($day,$month,$year) = localtime($date)[3,4,5]; # cleanup raw localtime output $month++; $year = substr ($year, -2); # Print niceish (whitespace instead of 0) MM/DD/YY dates to string $date = sprintf "%2d/%2d/%2d", $month,$day,$year; #I'm reusing $date, I don't need its old value. # Fix whitespace. $date will now hold MM/DD/YY data. $date=~s/\s/0/g; print "MM/DD/YY:\t$date\n"; }