My guess is that you are not passing a valid filename to the sub.
Are you using strict and warnings?
Code:
use strict;
use warnings;
use Time::Local;
sub getTime
{
my $myfile=shift;
my $filestat = (stat($myfile))[9];
my $mystamp = scalar(localtime($filestat));
print "File Stamp " . $mystamp;
}
getTime("timestamp.pl");
Gives me:
Code:
C:\Temp>perl timestamp.pl
File Stamp Tue Aug 25 15:23:37 2009
But if I remove the 'use strict', 'use warnings' and 'my $myfile=shift' lines, I get the same output as you are getting, because this line:
Code:
my $filestat = (stat($myfile))[9];
has nothing to do a stat() on.