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

Re: [MacPerl] File Modification Date?



Hi Chilton,

> What's the best way to get the file modification date of a file?
> Can this be done cross-platform, or is it platform-specific?

>From page 314 of the (excellent) Perl Cookbook:

	$mod_time = (stat($file))[9];

This returns Epoch seconds to $mod_time. If you then need something readable:

	($sec,$min,$hours,$day_of_month,$month,$year,$wday,$yday,$isdst)
		= localtime($mod_time);

..and to avoid confusion, remember to do a...

	$real_month = $mon + 1;
	$real_year = $year + 1900;

That all should be cross-platform.

    -- Matt
     
Matt Henderson   |   matt@exponet.net   |    www.exponet.net
                 .                      .    
E x p o n e t   M e d i a  T e c h n o l o g i e s   G m b H
Full-Service Web Development & Engineering Services Provider




===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org