note
golux
Good catch -- thank you! That now works in the example I provided.
<c>
Result 'A quick brown fox jumps over the lazy dog.'
</c>
<p>The ironic thing is that I introduced the bug you found when moving to the shorter example; it's not in the original. The original code is much longer, and within a module I'm writing to handle SSH handshaking between a Client and remote Server. Both the original program and the example have the same symptoms though; the error message is the same.
</p><p>So I've got some work to do... I now have a working (finally!) example, and a longer program with the error. I'll work at it from both ends, and post what I find here. Ideally I did something else stupid in the original, and it'll be easy to find and fix.
</p><p><b>Edit</b>: Found it. Well, it was not as stupid as the short example perhaps. I wasn't getting the same data over the socket that I was sending. I kludged up some routines to calculate an md5sum on the data at different stages, and realized that, differing from what I believed about [mod://MIME::Base64], the encode_base64() method was inserting newline into the string. (I know my example didn't show the encode_base64() and decode_base64 methods(), but that was because I was getting the error without them).
</p><p>So I went back to the docs for [mod://MIME::Base64] and found:
<c>
encode_base64( $bytes )
encode_base64( $bytes, $eol );
Encode data by calling the encode_base64() function. The first
argument is the byte string to encode. The second argument is the
line-ending sequence to use. It is optional and defaults to "\n".
The returned encoded string is broken into lines of no more than 76
characters each and it will end with $eol unless it is empty. Pass
an empty string as second argument if you do not want the encoded
string to be broken into lines.
</c>
When I changed the $eol char from "<c>\n</c>" to "<c></c>", the Client was able to get the full string, and it fixed the problem. :D
<div class="pmsig"><div class="pmsig-941867">
<center><font size="-1">
<font color="#ff0000">say </font>
<font color="#ffbf3f">substr</font><font color="#c8871a">+</font><font color="#9f4f06">lc </font><font color="#711f79">crypt</font><font color="black">(<font color="#a9df2d">qw </font><font color="#4df9ff">$i3 </font><font color="#4db2ff">SI$</font>),4,5</font></font></center>
</div></div>
1213735
1213736