> -----Original Message-----
> From: steven mckean [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 23, 2002 9:07 PM
> To: [EMAIL PROTECTED]
> Subject: Packed data
>
>
> Perl Gurus,
>
> How does on pack say a 4 byte field "1234" into a 2 byte
> field "12","34"?
Do you mean BCD?
$s = pack('n', hex(1234));
$s now contains two bytes. The first is 00010010 and the second is
00110100, which are the BCD representations of 12 and 34.
The reverse operation is:
$n = sprintf('%x', unpack('n', $s))
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]