Suppose I have a filehandle $fh
. I can check its existence with -e $fh
or its file size with -s $fh
or a slew of additional information about the file. How can I get its last modified time stamp?
相关问题
- $ENV{$variable} in perl
- Is it possible to pass command-line arguments to @
- Lazily Reading a File in D
- Redirecting STDOUT and STDERR to a file, except fo
- Change first key of multi-dimensional Hash in perl
相关文章
- How to replace file-access references for a module
- Running a perl script on windows without extension
- Comparing speed of non-matching regexp
- Why is file_get_contents faster than memcache_get?
- Transactionally writing files in Node.js
- Can NOT List directory including space using Perl
- Extracting columns from text file using Perl one-l
- Lazy (ungreedy) matching multiple groups using reg
This is very old thread, but I tried using the solution and could not get the information out of File::stat. (Perl 5.10.1)
I had to do the following:
Just thought I share in case anyone else had the same trouble.
I think you're looking for the stat function (perldoc -f stat)
In particular, the 9th field (10th, index #9) of the returned list is the last modify time of the file in seconds since the epoch.
So:
my $last_modified = (stat($fh))[9];
On my FreeBSD system,
stat
just returns a bless.You need to extract
mtime
like this:or