Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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 ).

In reply to Re: Checking file Mod date by sifukurt
in thread Checking file Mod date by LostS

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • 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> <u> <ul>
  • 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 intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2023-11-30 20:14 GMT
Find Nodes?
    Voting Booth?

    No recent polls found