Sorry, I forgot those little details.
Both platforms are Linux, with a a 2.4.22 or later kernels, (though a client run on the same box as the server has the same issues). We are both running perl-5.8.2. The server and client are connecting via SSL, openssl-0.9.7d.
I tried the binmode suggestion but calling binmod($sock) causes an error stating there is no BINMODE handler in IO::Socket::SSL. Though through further testing, we have discovered that this issue isn't directly tied to $! and $@, though at first it was only manifesting itself when they were used. Now this odd behaviour seems to happen anytime a dynamic string is used. String literals seem to function fine.
Has any of the data you're transmitting been (possibly inadvertently) converted into UTF8? In this case, the length
of the string does not match the number of bytes it contains,
eg
my $s = "ab";
$s .= "\x{100}";
open F, ">/tmp/x";
print F $s;
close F;
printf "length = %d, size = %d\n", length $s, -s '/tmp/x';