#!/usr/bin/perl $|++; use strict; use warnings; use CGI; $SIG{PIPE} = sub { open my $fh, '>>', 'debug_cgi.txt'; print $fh "Debug: " . scalar localtime . " died PIPE.\n"; close $fh; CORE::die "Pipe: @_\n"; }; my $q = new CGI; print $q->header('text/plain'); print "output #1\n"; warn "Debug: RUNNING"; foreach my $nr ( 1 .. 10000000 ) { print "test text $nr\n"; } print "output #2\n"; END { open my $fh, '>>', 'debug_cgi.txt'; print $fh "Debug: END block.\n"; close $fh; }