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