in reply to Recursive sub efficiency

Nothing to do with efficiency but:

close (DIR);

Should be:

closedir (DIR);