Hi Matt, A very Good Morning, Need a small Info for my problem.

I have a directory named "X" which has many sub directories
"Y","Z","W" and many files about 20 , and these sub directories also
contain some more sub directories and files in them and those sub
directories also contain more directories and files.

I want to read all the files that exists across all the  directors,
subdirectories (only files list)  and need to display .

i tried until 2 loops , but unable to complete the logic well on a
whole. can u help me if u have any idea ,

Any thing is helpful.

Thanks In advance

My Code is like below:
---------------------------------------------------------------
print "Enter The Directory Path";
$dir = <STDIN>;
chomp($dir);
opendir(DIR, $dir) || die "Unable to open the directory";
@contents=readdir(DIR);
foreach $listitem ( @contents )
{
  if ( -d $listitem )
  {
    opendir(DIR,$listitem)
    @c2=readdir(DIR);
    foreach  $l2(@c2) {
      if (-d $l2) {
       print $l2;
       print " It's a directory!\n";
      }
      else
      {
       print $l2;
         print " It's a file!\n";
      }
    }
    }
    print $listitem;
  print " It's a directory!\n";
  }
  else
  {
  print $listitem;
    print " It's a file!\n";
  }
}
close(DIR);
--------------------------------------------------------------


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


Reply via email to