in reply to directory printing

Just a guess here...

HTML does not recognize carrige returns (or any other whitespace) for document spacing. You need the HTML tag
for this purpose. Within your while loop, add the following line...
while ($filename = readdir(HOMEDIR)) { print ("$filename\n"); print ("<br>\n"); }
Notice that it's not a bad idea keep your HTML source looking pretty by keeping those newline character in there. Hope that helps...