in reply to syntax of touch a file

Fascinating question.

First I tried open OUT, ">> $file" and close OUT but that didn't change the time of the file.

So I thought a bit, and tried open OUT, ">> $file" and print OUT '' and close OUT; but that didn't work either.

You could always do a system '/usr/bin/touch', $file but that requires knowing where your external touch program lies.

Then I read the source code to touch.c, found that it refers to a system call named utimes. Looked up utime in perldoc, and got the answer:

my $now = time; utime $now, $now, $file;

This changes both the last access time and last modification time to now.