# First, the current date is determined use Date::Simple::D8 (':all'); my $today = Date::Simple::D8->today(); my $end_date = $today; # Prompt user for start date and verify it print "Please enter the collection start date (YYYYMMDD): "; my $start_date = <>; chomp ($start_date); while ($start_date !~ (/\d\d\d\d\d\d\d\d/)) { print "ERROR: Invalid format! Start date (YYYYMMDD): "; $start_date = <>; chomp ($start_date); } while ($start_date < 18960101) { print "ERROR: Data prior to 18960101 is not available! Start date (YYYYMMDD): "; $start_date = <>; chomp ($start_date); } while ($start_date > "$today") { print "ERROR: Start date is in the future! Start date (YYYYMMDD): "; $start_date = <>; chomp ($start_date); } print "Thank you, collection will begin with $start_date\n"; # Ask user if most recent available date should be used as end date print "Would you like to collect through the most recent available date? (y/n): "; my $ans = <>; chomp ($ans); if ($ans eq "n" || $ans eq "N") { print "Please enter the collection end date (YYYYMMDD): "; my $end_date = <>; chomp ($end_date); while ($end_date !~ (/\d\d\d\d\d\d\d\d/)) { print "ERROR: Invalid format! End date (YYYYMMDD): "; $end_date = <>; chomp ($end_date); } while ($end_date < 18960101) { print "ERROR: Data prior to 18960101 is not available! End date (YYYYMMDD): "; $end_date = <>; chomp ($end_date); } while ($end_date > "$today") { print "ERROR: End date is in the future! End date (YYYYMMDD): "; $end_date = <>; chomp ($end_date); } print "Thank you, collection will end with $end_date\n"; }