in reply to Re^2: Stat not returning values for a directory on Windows XP
in thread Stat not returning values for a directory on Windows XP

Nothing I changed would cause that error to appear where it wasn't before. In fact, you should have gotten that error all along.

Furthermore, it might have been worth saying that you weren't using stat. The code I gave you is wrong.

use File::stat qw( stat ); sub DirCheck { my $_dir = $_[0]; my $_dirStat = stat($_dir) or die "Can't stat directory $_dir: $!\n"; print "Directory: $_dir\n"; for my $field (qw( dev ino mode nlink uid gid rdev size atime mtime ctime blksize blocks )) { print "$field: ", $_dirStat->$field(), "\n"; } my $_mtime = $_dirStat->mtime; print "Last Modified Time for $_dir: $_mtime\n"; }

I also removed the useless opendir, which also avoids the error you are getting.

Updated

Replies are listed 'Best First'.
Re^4: Stat not returning values for a directory on Windows XP
by scott_shea (Initiate) on Jan 18, 2010 at 20:15 UTC

    I guess it would have helped to include the area where I have the use File::stat... sigh. I did not want to post all 200+ lines of my script. In the code below I have the use statement from the original script as well as a copy of the variable I am passing in and the call itself. I hard coded the dir name until I get this piece working. I still get the "The dirfd function is unimplemented at DirStat.pl line 10."

    #use File::stat; my $_checkDir = "c:\\drivers"; &DirCheck($_checkDir); sub DirCheck { my $_dir = $_[0]; opendir(my $dh, $_dir) or die "Can't open directory $_dir: $!\n"; my $_dirStat = stat($dh) or die "Can't stat directory $_dir: $!\n"; closedir($dh); print "Directory: $_dir\n"; for my $field (qw( dev ino mode nlink uid gid rdev size atime mtime ctime blksize blocks )) { print "$field: ", $_dirStat->$field(), "\n"; } my $_mtime = $_dirStat->mtime; print "Last Modified Time for $_dir: $_mtime\n"; }
Re^4: Stat not returning values for a directory on Windows XP
by scott_shea (Initiate) on Jan 18, 2010 at 20:34 UTC

    THANKS! It worked

    I appreciate the help and guidance. I am sorry that it was basically rewriting my code for me. That was certainly not my intention. I am comparing your final to my original to note all of the errors.