#!/usr/bin/perl $|++; use strict; use warnings; use CGI::Fast; $SIG{PIPE} = sub { open my $fh, '>>', 'debug.txt'; print $fh "Debug: " . scalar localtime . " died PIPE.\n"; close $fh; CORE::die "Pipe: @_\n"; }; while ( my $q = new CGI::Fast ) { 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"; last if ( -M $ENV{'SCRIPT_FILENAME'} < 0 ); } END { open my $fh, '>>', 'debug.txt'; print $fh "Debug: END block.\n"; close $fh; }