home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!noc.near.net!chpc.chpc.org!shishir
- From: shishir@chpcchpc.org (Shishir Gundavaram)
- Subject: # of files in directory
- Message-ID: <1992Jul22.182940.1248@chpc.org>
- Keywords: Files, Perl, Directory, ls
- Sender: shishir@chpc (Shishir Gundavaram)
- Nntp-Posting-Host: chpc.chpc.org
- Organization: Center For High Perf. Computing of WPI; Marlboro Ma
- Date: Wed, 22 Jul 1992 18:29:40 GMT
- Lines: 20
-
- Hi,
-
- Can anyone please tell me if there an easy way in Perl to determine
- the number of files in a particular directory.
-
- One way I can think of to do this is:
-
- opendir (FILE, "/usr/bin");
- @some_array = grep (!/^\./, readdir (FILE));
- $number = $#some_array + 1;
- print "There are $number of files!";
-
- But this is messy.
-
-
- Thanks,
-
- --Shishir
-
-
-