How do I get a file's last modified time in Perl?

后端 未结 9 903
说谎
说谎 2020-12-13 03:36

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 informati

9条回答
  •  难免孤独
    2020-12-13 04:09

    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];

提交回复
热议问题