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

后端 未结 9 904
说谎
说谎 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:14

    On my FreeBSD system, stat just returns a bless.

    $VAR1 = bless( [
                     102,
                     8,
                     33188,
                     1,
                     0,
                     0,
                     661,
                     276,
                     1372816636,
                     1372755222,
                     1372755233,
                     32768,
                     8
                   ], 'File::stat' );
    

    You need to extract mtime like this:

    my @ABC = (stat($my_file));
    
    print "-----------$ABC['File::stat'][9] ------------------------\n";
    

    or

    print "-----------$ABC[0][9] ------------------------\n";
    

提交回复
热议问题