Loading ...
Sorry, an error occurred while loading the content.

get list of subdirectory

Expand Messages
  • shaileshsp@yahoo.com
    hi, i am quiet a beginner at perl, is there any way i can get a list of all the subdirectories in a folder.I have 4-5 level of folders within folders... when i
    Message 1 of 1 , Nov 1, 2001
    View Source
    • 0 Attachment
      hi,
      i am quiet a beginner at perl,
      is there any way i can get a list of all the subdirectories in a
      folder.I have 4-5 level of folders within folders...
      when i run my following program..it gives me only the first level of
      folders..

      i have a folder called TestPerl which contains floder called
      TestPerl1 and within this folder is another folder called TestPerl2
      but when i run the following code my @dirlist array only contains
      TestPerl1.

      my code:
      my @dirlist=();
      while (defined (my $subdir = readdir TestPerl )) {
      if ($subdir !~ /^\./){
      push @dirlist, $subdir;
      print " the subdirectory list = @dirlist\n";
      }
      }

      any type of help will be highly appreciated,
      thanking everyone..
      shailesh
    Your message has been successfully submitted and would be delivered to recipients shortly.