Weekly Countdown Problems - This script only works on certain days of the week!

They have: 66 posts

Joined: May 1999

My script is supposed to display the number of days until friday... sort of a weekly countdown... but it doesn't seem to work right. On Sundays, Mondays, and possibly a few other days, it doesn't work, while most days it does. Here's the script... please give me your suggestions!

#!/usr/bin/perl

print "Content-type: text/html\n\n";

($sec, $min, $hour, $mday, $mon, $year, $wday, $ydat, $isdst) =
localtime();
$count = 7 % ($wday+2);
print("$count\n");

Again, please drop any ideas you have here!

Ed Aronyk (Blur)
Divergent Digital Media

The secret of success is sincerity. Once you can fake that, you've got it made.

They have: 5,633 posts

Joined: Jan 1970

This will do the trick:

#!/usr/bin/perl

($sec, $min, $hour, $mday, $mon, $year, $wday, $ydat, $isdst) = localtime(time);
$count = 5 - $wday;
if ($wday = 6) {
$count = 6;
}
print "content-type: text/html\n\n";
print $count;

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.