in reply to Perl Stat Issue

If you use the File::stat module then stat returns an object that you have to access with the proper methods. Please read the docs of this module.

use Modern::Perl; use File::stat; opendir( DIR, 'c:/data' ) or die('Cannot open directory'); my @files = readdir(DIR); closedir DIR; foreach my $file (@files) { my $full_name = 'c:/data/' . $file; my $st = stat($full_name); my $mod = $st->mtime; say "Filename $full_name has the mod date of $mod"; }

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Replies are listed 'Best First'.
Re^2: Perl Stat Issue
by omegaweaponZ (Beadle) on Jun 26, 2013 at 15:24 UTC
    Update: It seems that actually saying use File::stat is the culript.... when commenting this out, I get an epoch time. Why the heck is this the case? Is File::stat not correctly where I assumed it was?
      Well, you added the use stat; line so you should have read that module's documentation which says:
      This module's default exports override the core stat() and lstat() functions, replacing them with versions that return "File::stat" objects. This object has methods that return the similarly named structure field name from the stat(2) function; namely, dev, ino, mode, nlink, uid, gid, rdev, size, atime, mtime, ctime, blksize, and blocks.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      My blog: Imperial Deltronics