Conal has asked for the wisdom of the Perl Monks concerning the following question:
i am not very good at this so please point out any others areas i might be messing up or could do better if you feel so inclined
now obviously subtracting 1 from the $mday variable is gonna leave me in a whole load crap. Can anyone suggest any ideas for what i can do to fix this please?use File::Copy; use Time::Local; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdist) = localtime +time; my $week="daily/Sun-23-Mar-2008/"; .... other code ######### daily file creation ######## ######################## #create new file for new day @ 1700 if ($hour == 17 && $min ==0 && min !=30) { qx(touch $week.$mday); } ##################### ### calculate REAL day ### by subtracting 1 from mday if hour > 00 and < 1700 ### WHATABOUT THE MONTH??? my $filemday = $mday; if ($hour < 17 && $hour >= 0) { $filemday = $filemday-1; } my $dayfile = $week.$filemday.".txt"; ### print data to file if (-e $dayfile) { open (DATA,">>$dayfile"); print DATA ""$hour:$min,some data\n"; close (DATA); } ... other code
thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: potential date and time issues / code cleanup
by ikegami (Patriarch) on Mar 23, 2008 at 05:21 UTC | |
|
Re: potential date and time issues / code cleanup
by walto (Pilgrim) on Mar 23, 2008 at 06:43 UTC | |
by Conal (Beadle) on Mar 23, 2008 at 17:29 UTC | |
|
Re: potential date and time issues / code cleanup
by nefigah (Monk) on Mar 23, 2008 at 06:22 UTC | |
|
Re: potential date and time issues / code cleanup
by wade (Pilgrim) on Mar 23, 2008 at 06:40 UTC | |
|
Re: potential date and time issues / code cleanup
by CountZero (Bishop) on Mar 23, 2008 at 19:23 UTC |