To send the output of die() and/or confess() to the browser, import the CGI::Carp subroutine 'fatalsToBrowser' to your program.
Example:
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
open(FILE, "nonexistantfile.txt") or die("Can't open file: $!\n");
By default, 'fatalsToBrowser' prints a message at the bottom of the page telling to contact the webmaster; if you want to change that line, you can do it using the 'set_message' routine.
Example:
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser set_message);
set_message("<hr>Error message from <a href=http://www.perlhowto.com>Perl HowTo</a>");
open(FILE, "nonexistantfile.txt") or die("Can't open file: $!\n");





