home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / perl / 7685 < prev    next >
Encoding:
Internet Message Format  |  1993-01-06  |  1.3 KB

  1. Path: sparky!uunet!haven.umd.edu!purdue!not-for-mail
  2. From: spaf@cs.purdue.edu (Gene Spafford)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: stat problem
  5. Date: 6 Jan 1993 12:49:43 -0500
  6. Organization: Department of Computer Sciences, Purdue University
  7. Lines: 24
  8. Message-ID: <1if63nINNrj0@uther.cs.purdue.edu>
  9. References: <jwh2.4.0@cornell.edu>
  10. NNTP-Posting-Host: uther.cs.purdue.edu
  11. In-reply-to: jwh2@cornell.edu's message of Wed, 6 Jan 1993 15:10:16 GMT
  12.  
  13. In addition to the response pointing out that you need the full path
  14. name (or, alternatively, you need to chdir to the directory you are
  15. examining), you should consider changing
  16.  
  17.     if( -d $file) { next; }
  18.     if( -B $file) { next; }
  19.     $one_file[$ct] = $file;
  20.     ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) = stat($one_file[$ct]);
  21. to
  22.     if( -d $file) { next; }
  23.     if( -B _) { next; }
  24.     $one_file[$ct] = $file;
  25.     ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size) = stat(_);
  26.  
  27. This saves on the number of underlying "stat" calls that need to be
  28. made.
  29.  
  30. Other optimizations (like using a single associative array and/or
  31. pruning) are left as an exercise to the reader. :-)
  32. -- 
  33. Gene Spafford
  34. Software Engineering Research Center & Dept. of Computer Sciences
  35. Purdue University, W. Lafayette IN 47907-1398
  36. Internet:  spaf@cs.purdue.edu    phone:  (317) 494-7825
  37.