Have you tried stat ("$dir/$file")?  If you just stat ($file), $file
would have to be the full path or a file in the current directory.  Do
you have a sample output you could share?

-Dgg

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
lorid
Sent: Wednesday, July 20, 2005 3:34 PM
To: perl-win32-users
Subject: help with getting file stats


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
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to