Link to home
Start Free TrialLog in
Avatar of koko973
koko973

asked on

How can I get a timestamp of a file in Windows32 system?

I'm reading Windows directry & try to get the timestamps for a file (Last Modified, Last Accessed, File Created). I know there is a function 'stat' or 'lstat' for Unix based perl, but these are not supported in Windows env... Please help me.
Avatar of bebonham
bebonham

use dir


 /T          Controls which time field displayed or used for sorting
 timefield   C  Creation
             A  Last Access
             W  Last Written


I will see if I can come up with a sub for you.
short and sloppy...

but it'll get you by.


ts("A");

sub ts
{
$v=shift;
$ret=`dir /T$v`;
@arr=split("\n",$ret);


foreach(@arr)
{
$_=/([^ap]+)(.)/;
push(@arr2,$1 . $2);
}
print join("\n",@arr2);
print "done";
}

ASKER CERTIFIED SOLUTION
Avatar of bebonham
bebonham

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of koko973

ASKER

You are good!!!
Thanks a lot :-) Much appreciated.

anytime!!