in reply to Re: Re: $! and $@ peculiarities
in thread $! and $@ peculiarities

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';
gives
Wide character in print at /tmp/p line 7. length = 3, size = 4