Not to complicate matters, but you could also use
stat(). Using
stat() is particularly useful if you want to see the actual datestamp that the file was last modified, whereas -M only returns the number of days since modification. It is possible to get get the actual datestamp if you've only used -M, but you'd have to use Date::Manip. To do the whole process using
stat(), you could do it something like this:
$sevenDays = 60 * 60 * 24 * 7;
$now = time();
foreach $file ( @files ) {
$mod_time = ( stat($file) )[9];
if ( $now - $sevenDays < $mod_time ) {
# Our file has been modified w/i last 7 days
} else {
# Hasn't been modified w/i last 7 days
}
}
It is then a trivial matter to retrieve the exact date of the modification, like so:
$date = localtime( (stat($file) )[9] );
Or, using the first example, since we've already got the modification time stored in
$mod_time, we'd simply have to use
$date = localtime( $mod_time ).
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.