Editing files while keeping {A,C,M}-time
On most stat implementations, there are three separate time fields in the structure
atime
is access time,
mtime
is modification time,
and
ctime
is change time.
What you might notice; there isn't any creation time.
So for example, in my implementation of this site's generator, I sort the posts by their creation date, but since there is actually no creation date, I use the initial mtime.
Meaning, I constantly set the mtime to the initial mtime
after modifying the file.
So in order to edit a files, I wrote this perl script
#!/usr/bin/perl
my $file = shift or die "usage: $0 <file> <fork> [args...]\n";
my $time = (stat $file)[9] or die $!;
system(@ARGV);
utime undef, $time, $file;