In terms of actually reducing the overall bulk, the first loop over @day_prefixes seems to be quite long with a lot of repetitive stuff.

Given how nicely you have kept variable names, param names and DB field names consistent, I'd wager that you'll find it fairly easy to reduce quite a bit of that code into a nested loop over these names. Use a hash keyed by field name to store values that should be sent to the DB, rather than using separate scalars named for each field -- e.g.:

$sql_statement = "update timecard set " foreach $fname ( keys %fieldhash ) { $sql_statement .= "$fname = $fieldhash{$fname}," if ( $fieldhash{$ +fname} ); } $sql_statement =~ s/,$/ WHERE /; $sql_statement .= "blah = blah etc...";
You might even find a way to extend the use of that hash so that the field names involved appear only once or twice in the whole subroutine, rather than several times (and likewise for other parameter/field sets). Personally, I always find it a nice feature when I can reduce the number of times that I write a given set of names in a script.

In reply to Re: Help paring down massive subroutine by graff
in thread Help paring down massive subroutine by Anonymous Monk

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.