... my $pid = fork; if ( ! defined $pid ) { die "Can't fork: $!" } if ( $pid ) { close $sock; } else { while( 1 ){ ...