in reply to (tye)Re: 12 bit ints pairs into 3 bytes
in thread 12 bit ints pairs into 3 bytes

Here's what I decided on:
if(defined($o)) { $o=substr(pack("N",$o | ($t{$string}<<12)),1,3); print F2 $o; undef $o; } else { $o=$t{$string}; }
I thought about "L" and chop, but thought N might be more portable. And for unpack:
$r=read(F1, $double, 3); ($double)=unpack(N,"\000$double"); $old_code=$double & 0xfff; $double >>= 12;

Replies are listed 'Best First'.
(tye)Re: final decision: the whole cookie!
by tye (Sage) on Mar 03, 2001 at 11:51 UTC

    Nice. "V" is as portable as "N" and would let you use chop, BTW.

            - tye (but my friends call me "Tye")