$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);