I don't want to confuse you, but since you are modifying the filenames, I would suggest an additional enhancement:
The reason for this is so that the directory listing sort order (alpha-numeric) will be the same as a more advanced sort order based upon the specific numeric Year and Month values.
Right now, your directory listing will come in this order:
2010-12-another-file.html 2010-7-this-is-an.html
I think you will like this better:
2010-07-this-is-an.html 2010-12-another-file.html
Of course with Perl, there are always a number of ways to do this.
Here are 2 ways that work well:
$month =~ s/^(\d)$/0$1/; # adds leading zero if there is just a single # digit- otherwise has no effect # *** I recommend this idea for # your application. **** $month = sprintf("%02d", $month); # re-assigns a new string value # to $month no matter what
Other ideas occured to me, but I believe that these are the two best alternatives.

In reply to Re: Grabbing year and month from filename by Marshall
in thread Grabbing year and month from filename by htmanning

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.