APA_Perl has asked for the wisdom of the Perl Monks concerning the following question:
Monks I beseech thee,
I am doing major edits to sgml files through regex. Basically I am taking the original file as a string, editing the string and then printing the string to a new file. I want the new file to retain the modified and accessed dates of the original file. Here's my attempt so far:
$atime = (stat($found_file))[8]; $mtime = (stat($found_file))[9]; $time = ctime($date_string); $sgml_string = finalProcess($sgml_string); $new_str = substr($found_file, 0, index($found_file,'.new')) . '.new'; open (NEW_STR, ">$new_str"); print NEW_STR $sgml_string; close NEW_STR; unlink($found_file); rename ($new_str, $found_file); utime ($atime, $mtime, $new_str);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Apply mtime and atime to new file
by gjb (Vicar) on Dec 08, 2003 at 15:53 UTC | |
|
Re: Apply mtime and atime to new file
by shenme (Priest) on Dec 08, 2003 at 15:57 UTC | |
by APA_Perl (Novice) on Dec 08, 2003 at 16:28 UTC | |
|
Re: Apply mtime and atime to new file
by duff (Parson) on Dec 08, 2003 at 15:53 UTC | |
|
Re: Apply mtime and atime to new file
by Abigail-II (Bishop) on Dec 08, 2003 at 16:20 UTC | |
by APA_Perl (Novice) on Dec 08, 2003 at 16:55 UTC | |
by Abigail-II (Bishop) on Dec 08, 2003 at 17:06 UTC | |
|
Re: Apply mtime and atime to new file
by PodMaster (Abbot) on Dec 08, 2003 at 15:53 UTC | |
by duff (Parson) on Dec 08, 2003 at 15:58 UTC |