CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Frequently Asked Questions:
How do I set a file's timestamp in perl?

 



Jasmine
Administrator

Jan 26, 2001, 10:28 AM

Post #1 of 1 (1807 views)
How do I set a file's timestamp in perl? Can't Post

(From the Perl FAQ)

How do I set a file's timestamp in perl?

You use the utime() function documented in utime. By way of example, here's a little program that copies the read and write times from its first argument to all the rest of them.

Code
    if (@ARGV < 2) { 
die "usage: cptimes timestamp_file other_files ...\n";
}
$timestamp = shift;
($atime, $mtime) = (stat($timestamp))[8,9];
utime $atime, $mtime, @ARGV;

Error checking is left as an exercise for the reader.

Note that utime() currently doesn't work correctly with Win95/NT ports. A bug has been reported. Check it carefully before using it on those platforms.


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives