http://qs321.pair.com?node_id=202128

krisahoch has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks,

I am trying to write a simple web page that checks your IP address. If your ip address is okay (I have a list that is checked against), then the page allows you to log into the web site. If you IP address is not okay, then it should give the 404 error.

The login part, and address checking part is no biggie, simple stuff really. The tricky part is getting the 404 error to display in the browser. Here is the code snippit that I currently use to send back the 404 error.

#!/bin/perl use strict; use warnings; sub NotFound { return '404'; } use CGI::Pretty; use CGI::Carp qw(fatalsToBrowser); $CGI::Pretty::INDENT = ' '; my $WP = new CGI::Pretty; print $WP->header(-status => &NotFound);

The code sends back the following.

Status: 404 Content-type: text/html; charset=ISO=8859-1
but in a browser it sends a blank screen. A view source reveals the following...
<html><body></body></html>

What I want it to send back is the normal 404 error page for the particular web browser that you are using. Click on this link 404 Error to see what I am after.

If anyone has had any experiance with this, then please let me know. I'd hate to be wasting my time on this.

Thanks yall

Kristofer Hoch