in reply to Directory Listing to an Array
Your routine is named "listfiles", but it does more than just list files (it also lists directories, FIFO pipes, sockets, etc...) Also, it appears that you will skip any dot-files ( such as '.cshrc' ), not just '.' and '..'. Depending on what you are using this for, that might not be optimal.
sub listfiles { my $path = shift || '.'; opendir ( DIR, $path ) or die "Can't open path: $!\n"; return grep { -f "$path/$_" } readdir ( DIR ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Directory Listing to an Array
by particle (Vicar) on Apr 11, 2002 at 01:26 UTC | |
by ehdonhon (Curate) on Apr 11, 2002 at 11:41 UTC |