while ($input = <$client>) { $input =~ s/\r\n//g; # kill CR and NL chars $input =~ /^Content-Length: (\S*)/i && ($content_length=$1); ... more code .... ## find a blank line and we already have the content length then read the POST data if (length($input) == 0 && $content_length > 0) { $client->recv($form_content,$content_length); } }