in reply to Creating / Chmoding new files

The simplest approach I know would be to use the builting chmod command as added to your code below:
open (INDEX,">../../directory/$filename.htm") || &error_html("Could not page: $!"); chmod 0400, "../../directory/$filename.htm"; print INDEX qq~ ~; close (INDEX);
Hope that helps.

Vavoom