in reply to Too many files

The entries . and .. are created by the operating system and will always exist in every directory. Normally the command that lists the files in a directory (e.g. ls on Unix systems or dir on Windows) doesn't show them, but they are there nonetheless. It's the job of your script to ignore them.

One way is to simply test for them:

opendir(D, "/some/directory"); my @entries = readdir(D); closedir(D); for my $f (@entries) { next if ($f eq "." or $f eq ".."); ... }
If you can safely ignore any files that begin with a dot, consider using glob() with a star:
my @entries = glob("/some/directory/*"); ...
A third way is to skip all entries that are not files:
opendir(D, "/some/dir"); my @entries = readdir(D); closedir(D); for my $f (@entries) { next unless -f "/some/dir/$f"; ... }

Replies are listed 'Best First'.
Re^2: Too many files
by ikegami (Patriarch) on Jun 03, 2008 at 20:07 UTC

    The entries . and .. are created by the operating system and will always exist in every directory.

    Nit: They don't exist in the root directory on Windows.

Re^2: Too many files
by nessundorma (Initiate) on Jun 03, 2008 at 16:30 UTC
    Yes, I figured they were the current/parent directories, but I am unsure how to skip over them. I've tried a few different lines in my code, but none of them work and I feel like I'm missing something obvious...