A file open and close that doesnt modify a timestamp

G

gumby

I need to be able to open a file, read a file, then close a file with
out perl rewriting the TimeStamp on the file. I was able to do this
in C++ but not perl, and currently we are rewriting our old C code to
perl.

Here is what i am using currently
unless(open FILE, $fileName)
{
#here i pop an TK error window
}

while(<FILE>)
{
#Read and process the information so i can display it
}

close FILE;

I have looked into, since i already detect the timeStamp on the file,
keeping that timeStamp in memory then when i close the file using
utime to rewrite the Timestamp. I havent run any tests to see how
well that would work yet. Was just wondering if someone else has had
the same issue(I didnt see anything in the perldoc).
 
B

Ben Morrow

Quoth Jim Gibson said:
What operating system and version of Perl are you using? On my system
(Mac OS 10.3, perl 5.8.5), opening and reading a file changes none of
the file times atime, mtime, nor ctime.

A read of more than zero bytes ought to update the atime. Many systems
do not perform this update as a optimisation (under Linux, for example,
it is a mount-time option on most filesystems).

If the OP wants a last-mod-time he (?) wants to use the mtime. On
non-Unix OSen the meanings of the various times are different, and they
may be updated under different circumstances; the perlfoo (e.g.
perlwin32) page for your OS should say what they mean.

Ben
 
G

gumby

Jim Gibson said:
What operating system and version of Perl are you using? On my system
(Mac OS 10.3, perl 5.8.5), opening and reading a file changes none of
the file times atime, mtime, nor ctime.

We are currently using AIX. We have two file structures in place AFS,
and DFS. On the AIX system I have verfied that an open will change
the last modified time stamp on the file, where if i just ez the file
it wont change the last modified time stamp unless you save and exit.
I will look up some more info on the utime and how it works with AIX.
Thanks for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top