-----------8<---------------------------------------------------------------
-----
Using

my $filename = "$test";
my $mtime = (stat $filename)[9]; # or ctime is 10
my $time = time; # broke time out to print
my $age = int (($time - $mtime) / 86400); # did int to drop fraction
print "time=$time, mtime=$mtime, age=$age\n";

I get the following results:
time=1031216545 mtime= age=11935

Note there is no mtime? It must not be stating the file right? I have the
use File::stat; Any ideas past th is point?

-----------8<---------------------------------------------------------------
-----

Couple of things:

Please post your reply below the original post, and dont include
the person who replied your mail when you reply to them because
they are already in the list (if you get what I mean).

I guess you have had a really long day, and have been at this for hours.
We've been there too, so heres my $0.02:-

If you have pasted Bill's code directly, you would have got those results
because you didnt define what $test is.

If you included the following two lines at the top of
your program:-

use strict;
use warnings;

perl would have told you where youre coming from:-

C:\Perl\programs>stat.pl
Global symbol "$test" requires explicit package name at
C:\Perl\programs\stat.pl line 5.
Execution of C:\Perl\programs\stat.pl aborted due to compilation errors.

C:\Perl\programs>

mtime is blank because you are not stat'ng anything.

Replace $temp with the full path to your file including its name, as in:-

my $filename = "C:\\Temp\\Foo.bar";

Then you'll get the age of the last modification in days.

Hope that helps ; )


Just in - Engineer by name, butcher by profession . . .

perl -e "$_ = qx/perldoc -q japh/; s/.*\"(\w+ )(\w+ )(\w+
)\w{4}(\w+)\".*/ucfirst($1).\"in - $2\".ucfirst($3).\"us$4\"/es; print"
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to