My overall first impression is that this is pretty good code - subdivided into subroutines, nicely formatted, etc. It could be compacted / made mode "Perlish" in a couple places, but because TIMTOWTDI and the code is still clean and pretty easy to follow, I think it's fine the way it is. Just a few other issues / comments:
- Most importantly, you're using the system function with a single argument and with user input (command-line arguments), which is vulnerable to injections, and you're not checking the calls for errors. See Calling External Commands More Safely for alternatives.
- opendir also needs to be checked for errors, and it's better to use lexical file/dir handles, as in opendir(my $dh, $path) or die "$path: $!";.
- Instead of your sub pad, you can use sprintf, as in sprintf("%02d", $num).
- I would suggest you take the time to study Time::Piece and/or DateTime instead of the basic localtime stuff you're doing here, I think you'll be much happier in the long run.
- You may also want to consider looking into Getopt::Long to pass arguments to the script instead of a plain list of arguments. IMHO it makes for much more readable script invocations.
- Unless you're certain this will only ever be run on *NIX, you probably want to consider using a module for your filename manipulations. Personally I like Path::Class.
- Now we're getting very nitpicky, but do you really need to provide two different date formats? For things like this I'd always stick to YYYY-MM-DD.
Are you posting in the right place? Check out Where do I post X? to know for sure.
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
Want more info? How to link or
or How to display code and escape characters
are good places to start.