Category: | Miscellaneous |
Author/Contact Info | Rich Roberts rich@jesusstolemymoped.com |
Description: | I'm not overly certain how useful this will be to others, but I couldn't find anything that did the same thing. Basic concept is that it allows the user to time-stamp a weekly hours record, automagically creating each week's record. Not much in the way of error checking, and I'm positive that the user interface could be less clunky. On the plus side, there 'aint that much to it. The next trick will be to get it to email the timesheets as well! |
#!/usr/bin/perl # simple timesheet generator # step 1. Get the start date for the week use Date::Calc qw( Today Monday_of_Week Week_of_Year ); ($year,$month,$day) = Today(); ($year,$month,$day) = Monday_of_Week(Week_of_Year($year,$month,$day)); # step 2. See if this week's timesheet exists, if not, I'll create it unless (-e "$day-$month-$year.txt") { open(TIMESHEET,">$day-$month-$year.txt") || die("Cannot Open F +ile"); print TIMESHEET ("Timesheet for week commencing $day-$month-$y +ear\n"); } #If it does exist, we need to open it, for appending open(TIMESHEET,">>$day-$month-$year.txt") || die("Cannot Open File"); #Now, we present the user with his timesheet options. Start shift, end + shift, off, hols & sick... print "\n"; print "To start shift, push 1...\n"; print "To end shift, push 2...\n"; print "Off? push 3...\n"; print "Sick? push 4...\n"; print "Holiday? push 5...\n"; #get the times and 'tings, to use in a bit. ($wkday,$month,$day,$time,$year) = split(/\s+/, localtime); $dayname = substr((localtime ()), 0, 3); # finds day (three char code- + mon, tue etc.) from localtime chomp ($select = <STDIN>); #get the choice, then ye olde if statement +s for the printing if ($select == 1) { print TIMESHEET ("$dayname $time to "); } elsif ($select == 2) { print TIMESHEET ("$time \n"); } elsif ($select == 3) { print TIMESHEET ("$dayname off\n"); } elsif ($select == 4) { print TIMESHEET ("$dayname sick\n"); } elsif ($select == 5) { print TIMESHEET ("$dayname holiday\n"); } |
|
---|
Back to
Code Catacombs