touching a file should create it (as an empty file) if it does not exist or update its access and modification time to now if it does.
The utility of a piece of code that presumably does this:
sub touch {
open F, ">>$_[0]" or return undef;
seek F, 0, 2;
my $length = tell F;
print F 'A';
truncate F, $length;
close F;
return 1;
}
# presuming that the utime() function used in File::Touch is broken on
+ your system
# otherwise it would just be:
utime($a, $m, $file);
as a module seems a little dubious to me. I could write the code in far less time that it would take to download and install a module. On unix why not just shell to touch? I presume you want something for Win32 and this does the job.
Although it sound from your post like you are changing the contents of the file which if so is so bad as to defy belief. I could not imagine a circumstance where I would put up with random 'A' chars peppered through my file just because I wanted to change its M time. In text files this would be extremely annoying. For everything else it would probably break the file.
This snippet should work on any platform the lets you use seek to find EOF, tell to get the POS and truncate to undo the 'change' you made to the file. The net effect is touch like.
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|