note
BrowserUk
<blockquote><i>It doesn't give me a single format string that I can use to convert back and forth between "records" and "fields".</i></blockquote>
<p>The "problem" is that you cannot have a single conversion that produces binary numeric data for internal math use, and also produces asciified hex string for display purposes.
<P>It's the same as asking for a single printf format that will display an number as decimal and hex. It cannot be done.
<P>The solution is to have two templates: 1 for internal [pack]ing and [unpack]ing:
<code>
$templ = 'A4 v d';;
@fields = ( 'fred', 12345, 123.456 );;
$record = pack $templ, @fields;;
print unpack $templ, $record;;
fred 12345 123.456
</code>
<p>And another for unpack a record for display purposes:<code>
$templ2 = 'A4 H4 H16';;
print unpack $templ2, $record;;
fred 3930 77be9f1a2fdd5e40
</code>
<p>There is simply no way to implement a single template that would server both purposes.
<div class="pmsig"><div class="pmsig-171588">
<hr />
<font size=1 >
<div>Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.</div>
<div>"Science is about questioning the status quo. Questioning authority". </div>
<div>In the absence of evidence, opinion is indistinguishable from prejudice.</div>
</font>
</div></div>
534899
894777