The implementation can be very simple. Maintain two directories, unfinished/ and completed/. A download task can be represented by a file in unfinished/ whose name is the date of the desired download. When the download is complete, simply rename the file from the unfinished/ directory to the completed/ directory.
To add a download task, just create a new file in unfinished/ with the right name. This can be done via a cron job or even manually to redo a previous date.
Some more details...
Let's assume that the files in the unfinished/ directory have the form yyyy-mm-dd. Here's how to process each file:
To create a new download task for yesterday's games:opendir(D, "unfinished/") or die "unable to open unfinished/: $!\n"; my @files = readdir(D); closedir(D); for (@files) { next unless ($file =~ m/^(\d\d\d\d)-(\d\d)-(\d\d)$/); my ($year, $month, $day) = ($1, $2, $3); eval { ... process download for $year/$month/$day ... ... in case of an error, raise an exception with die ... }; if ($@) { warn "downloading for $year/$month/$date failed: $@\n"; } else { rename("unfinished/$file", "completed/$file"); } }
my @t = localtime(time-86400); my $y = $t[5]+1900; my $m = $t[4]+1; my $d = $t[3]; my $file = sprintf("%04d-%02d-%02d", $y, $m, $d); open(F, ">", "unfinished/$file"); close(F);
In reply to Re: Help with Time
by pc88mxer
in thread Help with Time
by TheAnswer1313
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |