in reply to Re: How to use pack/unpack data over a network
in thread How to use pack/unpack data over a network

On the sender's side we can go ahead and use the Z pack format, since we don't have to try processing it prematurely:
my $str_len = length($data); $str_len += (4 - $str_len % 4 || 4); print $sock pack("NZ$str_len", length($data), $data);
I started out thinking this would be a lot cleaner, but as you can see it doesn't look any better. *shrug*