you can open directories just like you can open files.
$dirname = "/tmp";
opendir(DIR, $dirname);
@files = readdir(DIR);
closedir(DIR);
now @files has the contents of your directory. you may want to print it before you do anything with it, because i don't remember if the firest two elements are . and .. or not.