My only concern is that common man does not easily understand the code in the Sub Filter

Depends on your definition of "common man". If the latter comprises one who does not know Perl at all, then your concern is justified. But then I don't know how it could be put in a form that is understandable to the "common man". Otherwise, anyone with basic Perl knowledge should not have any problem with it.

Let's check it together:

my %opt = @_;

Filter expects a list of key-value pairs as arguments, that will be put into a %opt hash. This is a common way to "fake" named arguments. Any problem with this?

( -d "$opt{ dir }/$_" ) # is a directory

-d is a test operator that should be well known and is documented in perldoc -f -X. It tests a string that interpolates some variables in an obvious way. Any problem with this?

&& !/^\./ # is also not hidden/special

Use of short circuiting &&: this expression is only evaluated if the former returned a true value. (The same goes on for the following lines, so I won't repeat that.) Any problem with this?

After the && you have a negated pattern match: you are checking that $_ doesn't match the expression. Any problem with this?

&& /(\d{4}_\d{2}_\d{2}_\d{2})/ # contains date/hour

Ditto as above, except that the pattern is slightly more complex: specifically you're searching a string comprising of 4 digits, a underscore, 2 digits, a underscore, 2 digits, a underscore, and last, other 2 digits. And you capture that string. Any problem with this?

&& ($opt{ now } gt $1 ) # that is in the past

You now compare as strings the value of $1, i.e. the string captured above, with another one, supposedly in the same format. Since these strings represent a time specification in an obvious manner, the string inequality also represents a chronological one. Any problem with this?


In reply to Re^3: Appropriately assigning times to variables by blazar
in thread Appropriately assigning times to variables by Win

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.