while(<$second>) { if($_ eq $match) { print $s_socket "$match\n"; scalar <$s_socket>; last; } }