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