[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] mod time



At 21.45 +0200 98-08-27, gene wrote:
>I haven't seen my post up here, so pardon me while I repeat:
>How do I get the modficiation time of a file using MacPerl?

-M $filename

returns the number of days since the file was last modified, measured from
the time the script started. If you want the time and date when it was
modified, you can subtract it from $^T, which is a special variable
containing the time (in seconds from Jan 1, 1970) when the script started:

$mod_date = $^T - (-M $filename);

If you want to print the date, you can use localtime:

print scalar localtime($mod_date);

localtime can also be called in array context if you want to extract the
day, month, year, etc. from the date:

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($mod_date);

If called without an argument, localtime uses the current time... But now
I'm diverging from your question :-)

Cajo.


___Carl_Johan_Berglund_________________________
   Adverb Information
   carl.johan.berglund@adverb.se
   http://www.adverb.se/



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch