Reading subdirectories

From: Colin (no_at_e-mail.com)
Date: 11/28/03


Date: Fri, 28 Nov 2003 17:28:43 -0000

Hi, I am trying to use the following code to read the contents of a several
subdirectories in a single directory.

opendir(MainDir, "/home/colin/data")
while ($file = readdir(MainDir) {
    print "$file\n";
    opendir(SubDir, $file)
    while($otherfiles = readdir(SubDir) {
         print "$otherfiles\n";
    }
}

Why can I not use $file to represent the directory I want to open in the
second opendir statement?
Can anyone help?

Thanks