my $b_err = 0; $SIG{'PIPE'} = sub { $b_err = 1 }; print $agent_socket $monitoring_node . ".lmonitor." . $monitoring_name . ".rtt.value=" . $latency . "\n"; if ($b_err) { # .... Handle the SIGPIPE error } #### print $agent_socket "$monitoring_node.lmonitor.$monitoring_name.rtt.value=. $latency .\n";