@sta[8] should be $sta[8] which would have been pointed out to you if you had use warnings;. You should also use strict;.
Since you used File::stat, perl's built-in stat function which returns an array has been replaced by a version that returns a blessed reference to an array. You can use this to access the elements of the array by name instead of by index. You could still use the array but you have to dereference first.
Using File::stat
use warnings; use strict; use File::stat; my $sta = stat($_); my @date = localtime($sta->atime); printf("%d-%d-%d\n",$date[4]+1,$date[3],$date[5]+1900);
or without
use warnings; use strict; my @sta = stat($_); my @date = localtime($sta[8]); printf("%d-%d-%d\n",$date[4]+1,$date[3],$date[5]+1900);
Update: After re-reading your post, I notice that you wanted modification time, not last access time. For that, use mtime instead of atime or offset 9 instead of offset 8.
--- print map { my ($m)=1<<hex($_)&11?' ':''; $m.=substr('AHJPacehklnorstu',hex($_),1) } split //,'2fde0abe76c36c914586c';
In reply to Re: win32 getting file modified details
by pfaut
in thread win32 getting file modified details
by rwallis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |