if ($buffer =~ /IEND/) { print $handle2 $buffer; read($handle1, $buffer, $bytes); ### 1 print $handle2 $buffer; ### 2 exit; }