Am wanting to get a list of files in a directory, but only
files which are not themselves further sub-directories.

When I do this...
	
   opendir(DIR, $this_path) or die "Can't opendir $this_path: $!";
   @file_list = glob("*");
   closedir(DIR);

...it gives all the files, including the files which are also
directories. Now on UNIX I can get a long list of all files, then grep
out the directories, then sed out all but the names on every line. That
works like so on NetBSD...

$file_list = `ls -l | grep -v "^d" | sed 's/.* //g'`;
@file_list = split /\n/, $file_list;
shift @file_list;

...which does exactly what I want. It lists the files which are not
directories.

But I am writing in Perl so as to NOT be OS dependent. I looked into the
-d test. But it seems an awful kludge to have to open every file and get
a status on it.

Is there a pure Perl way to get a list of file names exclusive of any
sub-directory names that will work multi-platform?

Thanks,

Gan

--

 Mistera Sturno - Rarest Extinct Bird

 <(+)__       Gan Uesli Starling
  ((__/)=-    Kalamazoo, MI, USA
   `||`
    ++        http://starling.us


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to