On Tuesday, May 28, 2002, at 09:25 , Sven Bentlage wrote:
> Hi ! > I'm trying to get all the date values for the week (7days) ahead of a > specified date. > To get the current date I use : > my ($d, $m, $y) = (localtime)[3,4,5]; > my $date = sprintf("%02d-%02d-%02d", >$d, $m+1, $y-100); > To get the date of the date 7 days ahead I use: > my ($da, $ma, $ya) = (localtime (time+ >(7*24*60*60)))[3,4,5]; > my $next_date = >sprintf("%02d-%02d-%02d", $da, $ma+1, $ya-100); your friend the loop would help here. use constant SECONDS_PER_DAY (24*60*60); my $day_ahead = 1; my $max_day_ahead = 7; for (; $day_ahead <= $max_day_ahead ; $day_ahead++ ) { my $tmp_t =( $day_ahead * SECONDS_PER_DAY); my ($da, $ma, $ya) = (localtime(time + $tmp_t))[3,4,5]; my $next_date = sprintf("%02d-%02d-%02d", $da, $ma+1, $ya-100); .... } you may want to do the perldoc on constant - since this will help you with more on how to think about writing self documenting code.... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]