1

I wrote this to find out the file creation time for a given file:

#!/usr/bin/perl
use strict;
use warnings;

use File::stat;

open (my $fh, '<', "abc.txt") or die "$!";
my $t = (stat($fh))[9];
print $t;

However, this does not work, and gives:

Use of uninitialized value $t in print at ./tests.plx line 9.

Can anyone point out what I'm doing wrong here? Or this can't be done on perl (5.14.2) on Windows/Cygwin, and I must choose some alternative method?

Thanks in advance.

  • http://stackoverflow.com/questions/509576/how-do-i-get-a-files-last-modified-time-in-perl –  Apr 20 '13 at 12:50

1 Answers1

4

stat from File::stat will return File::stat object. Remove use File::stat; to get array or use my $t = stat($fh); print $t->atime;.

Jack
  • 1,892
  • 1
  • 19
  • 23