I am trying to get the file stats
I found this code in ch8 of perl cookbook
( $dev, $ino, $mode, $nlink,
$uid, $gid, $rdev, $size,
$atime, $mtime, $ctime,
$blksize, $blocks ) = stat($filename)
and read the man page for stat and perlfunc but cant seem to get a
simple program to get the file stats
after reading the man page for stat I thought my problem might be that I
need to use fstat since the file may be open
but that doesnt seem to work either
any suggestions would be appreciated.
my simple test program:
#!/usr/local/bin/perl
use File::stat;
my $dir_ctr = 0;
my $file_ctr = 0;
my $dir = "/home/lorid/wrccpics";
print "Opening $dir \n";
opendir DH, $dir or die "Can't open the current dir $!\n";
while($file = readdir(DH)){
if(-d "$dir/$file"){
print "\n Dir: $file \n";
$dir_ctr++;
}
elsif(-e "$dir/$file"){
print "\nFile: $file \n";
( $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime,
$mtime, $ctime, $blksize, $blocks ) = stat($file);
print "\n $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size,
$atime,Mtime: $mtime,\n Ctime:$ctime,\n $blksize, $blocks\n";
$file_ctr++;
}
}
print "\n";
print "number of directories: $dir_ctr";
print "\n";
print "number of files: $file_ctr";
print "\n";
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs