#!/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"); }

In reply to weekly timesheet generator by multijoy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.