user2064000
user2064000

Reputation:

Unable to determine file creation time with perl on Windows/Cygwin

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.

Upvotes: 1

Views: 584

Answers (1)

Jack
Jack

Reputation: 1912

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

Upvotes: 4

Related Questions