You can also just do a sysread() for binary data, if you're not going to mix it with buffered reads/writes. I would add a test for the linefeed afterwards, to detect the case where the connection drops in the middle.
-- Snazzy tagline here
Comment on Re: Re: IO:Socket::INET - how to receive binary data
I prefer to use read over sysread and recv because it works with buffered I/O operations while the other two don't. Though if you are using UDP in certain ways, then you might want to use recv so you can get the source address for each packet. In rare cases, the "flags" argument to recv can also come in handy so that you can MSG_PEEK at the data without reading it or check for out-of-band data.