Accepting input for $date should be written as

my $date = shift || '12/DEC/2001:17:23:09';

The means you can enter a value on the command line without having to edit your script, and if nothing is supplied a default value will be used.

The creation of the %month hash is better written using the pair operator =>. Also, since you never modify it, it is even better to define it as a constant. And finally, through the wonders of human perception finding it easier to scan columns, the betterer way would be something like:

use constant MONTH => { Jan => 1, Apr => 4, Jul => 7, Oct => 10, Fen => 2, May => 5, Aug => 8, Nov => 11, Mar => 3, Jun => 6, Sep => 9, Dec => 12, }; ... my $mon = MONTH->{$mon};

Minor usability quibble: programs that gratuitously clear the screen make me want to reach for the bazooka. Don't do it, or at least do it in a portable way, and don't do it if the code is not being run from a tty.

--
g r i n d e r
just another bofh

print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u';

In reply to Re: Epoch Conversion by grinder
in thread Epoch Conversion by JoeCool

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.