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