in reply to using pack() to build a 16 bit word


Here is one way to do it:
#!/usr/bin/perl -wl use strict; my $posture = 2; my $app_width = 5; my $structure = 6; my $style_word = $posture; $style_word |= $app_width << 2; $style_word |= $structure << 5; $style_word = pack 'n', $style_word; print unpack "B*", $style_word; __END__ Prints: 0000000011010110
You can also use the %b format in sprintf to debug the unpacked integer (perl5.6 and later):
my $style_word2 = $posture | $app_width << 2 | $structure << 5; printf "%016b\n", $style_word2;

--
John.