$/ = CRLF . CRLF; #To read the whole header as one 'line' binmode $CONN; #Turn off \n conversion for getline() in next line my $header = $CONN->getline; $header =~ s/$CRLF/\n/g; say $header; --output:-- HTTP/1.1 200 OK Date: Sun, 21 Feb 2010 12:28:24 GMT Server: Apache/2.2.4 (Unix) mod_ssl/2.2.4 OpenSSL/0.9.7l DAV/2 PHP/5.2.3 mod_python/3.3.1 Python/2.4.4 Content-Length: 294 Connection: close Content-Type: text/html