home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!mips!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!bobd
- From: bobd@magnus.acs.ohio-state.edu (Bob DeBula)
- Newsgroups: comp.lang.perl
- Subject: Re: # of files in directory
- Keywords: Files, Perl, Directory, ls
- Message-ID: <1992Jul23.195931.20791@magnus.acs.ohio-state.edu>
- Date: 23 Jul 92 19:59:31 GMT
- References: <1992Jul22.182940.1248@chpc.org> <1992Jul22.150613.26006@hemlock.cray.com>
- Sender: news@magnus.acs.ohio-state.edu
- Organization: The Ohio State University
- Lines: 24
- Nntp-Posting-Host: photon.magnus.acs.ohio-state.edu
-
- In article <1992Jul22.150613.26006@hemlock.cray.com> roehrich@cray.com (Dean Roehrich) writes:
- >
- >You can throw out the $number stuff. Remember that $#array gives you the
- >subscript of the last element while scalar( @array ) gives you the length of
- >the array. (Also, you did not compensate for $[.)
- >
- >Replace your last 2 lines with:
- > print "There are ", scalar @some_array, " files!\n";
- >
-
- 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.....
- --
- ==========================================================================
- Disclaimer: These are my views, not the U's
-
- "If it's in the paper it must be true!" --- D. Doright
-