in reply to win32 getting file modified details

@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';

Replies are listed 'Best First'.
Re: Re: win32 getting file modified details
by rwallis (Initiate) on Jan 12, 2003 at 16:32 UTC
    hi there pfaut, thanks very much, that worked a treat.