jettero - Of course! I consider all sorts of options except for the obvious. If hold on to the value then I don't have to call stat() again.
Fletch - Thanks. I didn't know about the _ filehandle. It will probably be very efficient to check stat(_) since it is already present and being populated behind the secenes anyway.
I'll go benchmark these two approaches and see if there is any extra overhead to accessing _ with stat() versus keeping and populating my own scalar.
EDIT: Benchmarking shows that there is very little difference between the two methods. The only significant finding was that any method using one call (storing the timestamp to a scalar, stat()ing the auto-populated _ filehandle or even my original warning-prone check) is roughly twice as fast as stat()ing twice to check for existance then for a new timestamp.
With enough effort I was able to measure that storing to a scalar is about 1.5% faster than calling stat() on _. The warning-prone check is less than half a percent faster than that when the config file always exists and is about 5% slower when the config file is missing (even with STDERR closed so warnings don't go anywhere).
Bottom line: For my purposes the simplest/most direct method of storing the timestamp to a scalar then checking for definedness then difference is the most efficient method that shouldn't throw warnings. Thanks again.
In reply to Re: Most efficient File Modified check (w/o warnings)
by Cefu
in thread Most efficient File Modified check (w/o warnings)
by Cefu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |