home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / perl / 7681 < prev    next >
Encoding:
Text File  |  1993-01-06  |  1.3 KB  |  53 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!newsstand.cit.cornell.edu!cornell.edu!jwh2
  3. From: jwh2@cornell.edu (James W. Howell)
  4. Subject: stat problem
  5. Message-ID: <jwh2.4.0@cornell.edu>
  6. Summary: stat doesn't return anything when dealing large numbers of files.
  7. Keywords: stat large amounts of files.
  8. Lines: 38
  9. Sender: news@mail.cornell.edu
  10. Nntp-Posting-Host: smbass.cit.cornell.edu
  11. Nntp-Posting-User: @cornell.edu
  12. Organization: Cornell University
  13. Date: Wed, 6 Jan 1993 15:10:16 GMT
  14.  
  15. Using the below perl script the stat routine doesn't return anything, has 
  16. anyone seen this type of behavior before???
  17. Jim Howell
  18.  
  19.  
  20. #!/usr/bin/perl
  21.  
  22.  
  23. $usr_spool_dir = "/usr/include";
  24. # $usr_spool_dir = "/usr/spool/mail/jwhtest";
  25. # $usr_spool_dir = "./";
  26.  
  27. opendir(SDIR,$usr_spool_dir);
  28.  
  29. @dir_files = readdir(SDIR);
  30.  
  31. $ct = 0;
  32. foreach $file (@dir_files)   {
  33.     if( -d $file) { next; }
  34.     if( -B $file) { next; }
  35.     $one_file[$ct] = $file;
  36.     ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) = stat($one_file[$ct]);
  37.     $file_size[$ct] = $size;
  38.     print "$dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size " ;
  39.     print "file = $one_file[$ct]  size = $size     \n";
  40.     $ct = $ct + 1;
  41. }
  42.  
  43. closedir(SDIR);
  44.  
  45. @sorted_big_files = sort bynumber  @file_size;
  46.  
  47. for ( $x=0; $x<=$ct; $x++ )    {
  48.     print "$sorted_big_files[$x] \n";
  49.     if($x>=10) { exit 0 ; }    # I only want to see the top ten.
  50. }
  51.  
  52. sub bynumber { $b <=> $a; }
  53.