Last modified time
Win
created: 2006-04-05 09:03:31
Please can people explain how I can get perl to check the last modified date of the program that is running (in windows). Also, how do you get it from another program that is not running?
Re: Last modified time
created: 2006-04-05 09:09:34

You can get the last modified time of a file using stat. But I don't know how you expect to get it using a program that is not running.


We're not surrounded, we're in a target-rich environment!
Re^2: Last modified time
created: 2006-04-05 09:37:40

You've obviously never read any of Win's other gems . . .

Re: Last modified time
created: 2006-04-05 09:13:49

stat ought to work. $0 should provide the argument for the current running program. If that doesn't work, look at perlport and perlwin32 to see what changes you need.

For some other program, just use its path/filename as argument to stat.

After Compline,
Zaxo

Re: Last modified time
created: 2006-04-05 09:22:59
Hi Win, Try this
$modifytime = (stat($filename))[9];
print $modifytime;
Regards
Perlsen
Re^2: Last modified time
Win
created: 2006-04-05 10:06:36
It returns the following:

114424****

I can't make head or tail of it. Each star represents a number. I didn't give the full number because I don't like to when I'm not sure what it means.
Re^3: Last modified time
created: 2006-04-05 10:21:49
stat returns the modify time in "number of seconds since epoc", so you get a large number. You can convert this to a readable format using localtime, for example:
my $mod = (stat $0)[9];
print scalar localtime($mod);
You can create your own date formats by getting the local time in "broken-down" format, see perldoc -f localtime, or using POSIX::strftime.
Re^4: Last modified time
created: 2006-04-05 10:23:43
See also time, which returns the current time ("now") in the same format.

perlmonks.org content © perlmonks.org and bart, cdarke, Fletch, jasonk, perlsen, Win, Zaxo

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03