or download this
# -----------------------------------------------------------------
# Perl network programming notes
...
# This one may return less than asked for (like read()/recv() in C)
my $msglen = sysread( $client, $data, $SYSLOG_MAX_MSG_LEN );