in reply to Why does this crash? (Error 500)

I don't know why your program crashes but it is probably a good idea to redirect STDOUT and STDERR. Your last two lines are "really" doing:

print STDOUT "Content-type: text/html\n\n"; print STDOUT "$timepage";

So you may find the following snippet (mostly from the Camel) usefull

open SAVEOUT, ">&STDOUT"; open STDOUT, ">/tmp/stdout.save"; . . print STDOUT "Content-type: text/html\n\n"; print STDOUT "$timepage"; . . open STDOUT,">&SAVEOUT";

That's from memory so I wouldn't trust it

Update:You should of course do the same for STDERR