home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / perl / 4918 < prev    next >
Encoding:
Internet Message Format  |  1992-07-23  |  1.4 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!mips!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!bobd
  2. From: bobd@magnus.acs.ohio-state.edu (Bob DeBula)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: # of files in directory
  5. Keywords: Files, Perl, Directory, ls
  6. Message-ID: <1992Jul23.195931.20791@magnus.acs.ohio-state.edu>
  7. Date: 23 Jul 92 19:59:31 GMT
  8. References: <1992Jul22.182940.1248@chpc.org> <1992Jul22.150613.26006@hemlock.cray.com>
  9. Sender: news@magnus.acs.ohio-state.edu
  10. Organization: The Ohio State University
  11. Lines: 24
  12. Nntp-Posting-Host: photon.magnus.acs.ohio-state.edu
  13.  
  14. In article <1992Jul22.150613.26006@hemlock.cray.com> roehrich@cray.com (Dean Roehrich) writes:
  15. >
  16. >You can throw out the $number stuff.  Remember that $#array gives you the
  17. >subscript of the last element while scalar( @array ) gives you the length of
  18. >the array.  (Also, you did not compensate for $[.)
  19. >
  20. >Replace your last 2 lines with:
  21. >    print "There are ", scalar @some_array, " files!\n";
  22. >
  23.  
  24. To reduce it still further (this *is* PERL after all):
  25.  
  26.  
  27. opendir (FILE, "/usr/bin");
  28. print "There are ", scalar(grep (!/^\./, readdir (FILE))), " files!\n";
  29.  
  30.  
  31. Now if I could just figure out how to embed the open in the print
  32. statement.....
  33. -- 
  34. ==========================================================================
  35.               Disclaimer: These are my views, not the U's
  36.  
  37.         "If it's in the paper it must be true!" --- D. Doright 
  38.