If skipping blank lines is okay, use next at the top of the while loop:

while(<CONF_ID>){ next unless /\S/; ... }

That is, unless the line contains a non-whitespace character, jump to the next iteration of the loop.

As for cleaning up your code, you have a lot of duplication and near duplication, especially reading your templates. If you factored that code out into a subroutine, you could make your program shorter. Of course, you could also skip re-reading the templates for every line of input, which would make your program faster.

To do that, you need to extract other subroutines which only do one thing: read a file into a data structure, perform a substitution for every line of a data structure, write out a data structure to a file. Your code will be easier to read and modify because each individual unit has a descriptive name and a single, identifiable purpose.

Style-wise, eschew global filehandles in favor of lexical filehandles and get rid of the prototype on getDate(). If you do the latter, you can drop the Perl 4-style invocation. Other than that, you use more parentheses than I would, which is mostly a matter of familiarity with Perl, so don't worry about that for now.


In reply to Re: Error Correction by chromatic
in thread Error Correction by PyrexKidd

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.