in reply to Die function misfunctions

The other posters are correct. For the sake of learning, though, what happens if you print the HTTP header before anything has a chance to die?

On my box, that prevents the 500 error, but produces a page with no displayable data.

die sends the message to STDERR, which normally goes into your server error log. Depending on what's been sent to STDOUT (the user agent), the web server may have to send error information.

If I were you, though, I'd use Carp and fatalsToBrowser during development instead of die, and work up some sort of error reporting mechanism that logs errors and reports them to users gracefully for production.