Hi can anyone kindly help me out with making this code more robust and useful.. for the purposes of the data i am working with days start at 5pm and finish at 4.59pm the next day. i have a data file for each day containing my readings
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
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
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?
thanks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.