J Krugman said:
Suppose that I have a Perl variable tied to some file. Does Perl
provide any facilities for preventing some other program from
modifying this file, and/or for detecting if such modification
happens? (I'm only interested in the UNIX case).
TIA!
You could unlink the filename which the variable is tied to, so that the
only remaining link to the file inode is the one held by the perl program.
That should stop all but the most dedicated superusers from messing with
it. This still leaves a brief period in which someone could grab the file,
so to be even safer, you should avoid ever creating the filename entry in
the filesystem in the first place.
perldoc -f open:
As a special case the 3 arg form with a read/write mode and the
third argument being "undef":
open(TMP, "+>", undef) or die ...
opens a filehandle to an anonymous temporary file.
Of course doing this means that the filedata will be lost as soon as your
program exits, so I hope that that is OK with you.
Xho