Nishi Bhonsle wrote:
>
> I am not able to get the files at just the first level.
> ie
>  print "$_\n" for $io->all(0);  prints all level down
> and
>  print "$_\n" for $io->all(1); prints the files and the dir name at the
> first level
> ie
> issuing the command for path C:\build\Sample\NewDir
> prints the below
> C:\build\Sample\NewDir\File1.txt
> C:\build\Sample\NewDir\File2.txt
> C:\build\Sample\NewDir\NewSubDirectory
>
> In my case, I am not interested in the directory listing but only file
> listing.
>
> I didnt find anything in IO:All that would give me only file listing
> under a particular directory without including the subdirectory listing.

Hi Nishi.

We seem to be going round in circles here. I suggested File::Find because I
thought you wanted to find stuff nested in a directory structure. If all you
want is a list of plain files in a directory you don't need any modules at all.
Try:

  use strict;
  use warnings;

  my @dir = do {
    opendir my $dh, 'C:\build\Sample\NewDir' or die $!;
    grep -f, readdir $dh;
  };

  print "$_\n" foreach @dir;

Is this what you want?

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to