Or have your own onload event that will automatically close the windows that are opened.
use CGI qw(:all);
use CGI qw(fatalsToBrowser);
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>404 Page not found</title>
Your 404 message here
Server's do not statically modify HTML documents on the server. It is attached to whatever output is being sent to the client. In the case of a Perl script, whatever output it produces will be modified to include the server's script header and then passed to the client.