home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / perl / 4924 < prev    next >
Encoding:
Text File  |  1992-07-23  |  2.3 KB  |  55 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!caen!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!bobd
  3. From: bobd@magnus.acs.ohio-state.edu (Bob DeBula)
  4. Subject: Re: # of files in directory
  5. Message-ID: <1992Jul23.211249.21744@magnus.acs.ohio-state.edu>
  6. Keywords: Files, Perl, Directory, ls
  7. Sender: news@magnus.acs.ohio-state.edu
  8. Nntp-Posting-Host: photon.magnus.acs.ohio-state.edu
  9. Organization: The Ohio State University
  10. References: <1992Jul22.150613.26006@hemlock.cray.com> <1992Jul23.195931.20791@magnus.acs.ohio-state.edu> <1992Jul23.201539.4416@news.eng.convex.com>
  11. Date: Thu, 23 Jul 1992 21:12:49 GMT
  12. Lines: 41
  13.  
  14. In article <1992Jul23.201539.4416@news.eng.convex.com> tchrist@convex.COM (Tom Christiansen) writes:
  15. >From the keyboard of bobd@magnus.acs.ohio-state.edu (Bob DeBula):
  16. >:To reduce it still further (this *is* PERL after all):
  17. >:
  18. >:opendir (FILE, "/usr/bin");
  19. >:print "There are ", scalar(grep (!/^\./, readdir (FILE))), " files!\n";
  20. >:
  21. >:Now if I could just figure out how to embed the open in the print
  22. >:statement.....
  23. >
  24. >print "There are ", scalar grep(1,`ls /usr/bin/`), " files in /usr/bin.\n";
  25.                    ^^^^^^^^^^^^^^
  26.                    But, that would 
  27.                    be *cheating* :-)
  28.                 
  29.  
  30. Actually, how does this compare in efficiency to the "opendir"
  31. method? (My timings would seem to indicate that the "opendir" form
  32. is slightly (almost infintesimally) faster on my Sun 3/80).
  33.  
  34. While the goal is to get it down to one line, you must color
  35. in the lines (stay within PERL that is :-). So, can you do it
  36. in one line *without* using any semi-colons or backquoting
  37. to use external utilities? Think of it as one of those penultimately
  38. pointless PERL challenges which crop up from time to time :-)
  39.  
  40. Hmmm, "Penultimately Pointless PERL Programming Problem" sounds
  41. like some sort of invitational named by Robin Leach, doesn't it? 
  42. What would we give for a prize to the winner of the 1st PPPPP 
  43. Invitational? Maybe we could get Larry to donate some "suitable 
  44. for framing" original napkins with PERL patches scribbled on them 
  45. (complete with obligatory coffee stains)?
  46.  
  47.  
  48. :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-) :-)
  49.  
  50. -- 
  51. ==========================================================================
  52.               Disclaimer: These are my views, not the U's
  53.  
  54.         "If it's in the paper it must be true!" --- D. Doright 
  55.