Re: Need a list of files in a dir.
- From: tallison@xxxxxxxxxxx (Tom Allison)
- Date: Mon, 26 Sep 2005 06:30:19 -0400
Wiggins d'Anconia wrote:
Please bottom post...
Daniel Kurtz wrote:
Ooh ooh ooh! One I know!
open(COMMAND, "dir |"); @files = <COMMAND>;
Well, there's two methods that I use where I can and they are probably more portable.
glob works well most of the time:
@files = </directory/goes/here/*>;
But it has problems with large numbers of files. And the problems will cause it to fail badly.
The other is to opendir and read in a loop.
In either case you need to remove the '.' and '..' entries:
@files = grep {! /^\./} </directory/goes/here/*>or something like that.
I should warn you, not only is this untested code, but I haven't even had my coffee yet.
.
- Follow-Ups:
- Re: Need a list of files in a dir.
- From: Bright True
- Re: Need a list of files in a dir.
- Prev by Date: Re: Error message >The process tried to write to a nonexistent pipe.
- Next by Date: Re: the time a program runs
- Previous by thread: Error message >The process tried to write to a nonexistent pipe.
- Next by thread: Re: Need a list of files in a dir.
- Index(es):