in reply to seeing all files in a directory

Also note that you must opendir() before readdir() will work.

Here's one alternative to readdir()... it assumes that $path is set appropriately, and you want all ".txt" files:
my @numfiles = glob("$path/*.txt");

Hot Pastrami