note
Athanasius
<p>Hello [BrowserUk],</p>
<p>As I understand it, <c>pack (A2)*, LIST</c> says: for each element in LIST, convert it to a 2-byte ASCII string, padded with a trailing space character if necessary; then return the concatenation of these converted elements as a single string.</p>
<p>Logically, then, since <c>unpack</c> “does the reverse of pack”, <c>unpack (A2)*, STRING</c> should break STRING into 2-character chunks, and for each chunk, first <i>remove</i> any trailing spaces, then convert it to an appropriate value. Which is what I see:</p>
<code>
2:03 >perl -MData::Dump -wE "my @c = unpack '(A2)*', 'f 12dx z'; dd \@c;"
["f", 12, "dx", " z"]
2:04 >
</code>
<p>Note that <c>"f "</c> has been converted to <c>"f"</c> by removal of the trailing space (padding).</p>
<p></p>
<blockquote>
<code>
print unpack 'C*', pack '(Z2)*', 'fr','ed','x';;
102 0 101 0 120 0 ## Note! the 'r' & 'd' characters have been thrown away? Another bug?
</code>
</blockquote>
<p>I don’t see a problem here, either. The template <c>Z2</c> specifies a 2-byte null-terminated string. Packing <c>'fr'</c> of course requires 3 bytes, so the second character is thrown away and the packed result is <c>f\0</c>. Isn’t that what it’s supposed to do?</p>
<p>Hope that helps (and I apologise if I’ve missed the point!),</p>
<div class="pmsig"><div class="pmsig-968231">
<p>
<table width="100%">
<tr>
<td align="left">
Athanasius <font color="#008000"><</font>[href://http://www.biblegateway.com/passage/?search=John%203:16&version=NLV|<font color="#008000">°</font>]<font color="#008000">(((><</font> <i>contra mundum</i>
</td>
<td align="right">
[href://http://translate.google.com.au/#la/en/Iustus%20alius%20egestas%20vitae%2C%20eros%20Piratica%2C|<b>Iustus alius egestas vitae, eros Piratica,</b>]
</td>
</tr>
</table>
</p>
</div></div>
1116868
1116868