[EMAIL PROTECTED] wrote:
> 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);
        If you look at the -d and -e you will see that it is concatenating the 
dir and file. You are only giving it the file and it does not exist.  You will 
need to either use the same setup of $dir/$file or you could do a chdir against 
the $dir and then the $file should work.

Wags ;)
>       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



*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************


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

Reply via email to