http://qs321.pair.com?node_id=997549


in reply to PERL Binary Data Handling

First of all, I want to congratulate you, as a newbie, for utilizing code tags :).

  1. While you may want 33 bits worth of data, when you write it, it will be 40-bits worth of data. You would be best served by explicitly defining all 40 bits in your pack operation
  2. pack takes string parameters. You're reading in a binary value, and passing that as the argument to pack. To do what you want, you should my $str = unpack ("b32", $buff); and then use $str as the second arg
  3. You probably want to use syswrite to do your output, rather than print

fnord