in reply to Create a html page on fly

Try adding or die "Cannot open $filename" to the end of that open line:
open HTML, ">tmp/$filename" or die "Cannot open $filename";
EDIT: Yeah, what chromatic and JavaFan already covered...