Hallo zusammen,
stimmt, die sind für Datumsangaben denkbar ungeeignet. Was Du suchst ist die Funktion stat:
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($filename);
Vermutlich suchst Du $mtime (Datum der letzten Änderung), also (stat($filename))[9]. Diese Zeit kannst Du wie gewohnt mit localtime verarbeiten und so jedes gewünschte Format herstellen.
(Weil ich es nie lassen kann)Kurzer Auschnitt aus der perlfaq-5
(da stehen nämlich auch 2 Beispiele ;-)
How do I get a file's timestamp in perl?
If you want to retrieve the time at which the file was last read, written, or had its meta-data (owner, etc) changed, you use the -M, -A, or -C filetest
operations as documented in the perlfunc manpage. These retrieve the age of the file (measured against the start-time of your program) in days as a floating
point number. To retrieve the ``raw'' time in seconds since the epoch, you would call the stat function, then use localtime(), gmtime(), or
POSIX::strftime() to convert this into human-readable form.
Here's an example:
$write_secs = (stat($file))[9];
printf "file %s updated at %s\n", $file,
scalar localtime($write_secs);
If you prefer something more legible, use the File::stat module (part of the standard distribution in version 5.004 and later):
# error checking left as an exercise for reader.
use File::stat;
use Time::localtime;
$date_string = ctime(stat($file)->mtime);
print "file $file updated at $date_string\n";
The POSIX::strftime() approach has the benefit of being, in theory, independent of the current locale. See the perllocale manpage for details.
Also beim nächsten Mal....
und nichts für ungut ;-)
Gruß
Christoph