On Tue, Aug 11, 2015 at 5:28 PM, John SJ Anderson <j...@genehack.org> wrote:

> On Tue, Aug 11, 2015 at 6:58 AM, John SJ Anderson <j...@genehack.org>
> wrote:
>
>> On Tue, Aug 11, 2015 at 5:24 AM, Chris Knipe <sav...@savage.za.org>
>> wrote:
>>
>>>
>>>
>>> my $numBytesToRead = 512;
>>>
>>> my $buffer;
>>>
>>> while ($bytesRead = read($TCPSocket, $buffer, $numBytesToRead)) {
>>>
>>>   if ($buffer =~ m/\r\n\.\r\n$/) {
>>>
>>>     print $buffer;
>>>
>>>     last;
>>>
>>>   }
>>>
>>> }
>>>
>>>
>>>
>>> I’m obviously doing this wrong :(  Can anyone perhaps show me the light?
>>>
>>>
>> Don't you need to put $bytesRead into $buffer at some point?
>>
>
> Wow, and this is why we don't review the code before the coffee... 8^/
>


Indeed... read() returns the number of bytes read, not the actual stream of
what HAS been read, unless of course I am again missing something...
http://perldoc.perl.org/functions/read.html

For the above, $bytesRead will be 512.  The stream that is read, is pushed
into $buffer

-- 

Regards,
Chris Knipe

Reply via email to