ashes3d has asked for the wisdom of the Perl Monks concerning the following question:
Hello All, I am a PERL newbie, and come from a hardware background. My question is with regards concatenating binary data in PERL. I am reading a 32-bit value (4 bytes) from a binary file. I would like to concatenate one bit in front of the value (new value will be 33 bits!) I have tried different variations of using pack, but either I don't think I understand pack command correctly, or B, PERL doesn't like my use of a 33 bit data. How should I fix this? Here is sample of what I am doing
open (PARSER_FILE, $inputfile) or die "Couldn't open $inputfile for reading"; binmode(PARSER_FILE); open (OUT_FILE, ">", $outputfile) or die "Couldn't open $outputfile for writing"; binmode(OUT_FILE); read(PARSER_FILE, $buff, 4) . . print OUT_FILE pack(b33, 1, $buff);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: PERL Binary Data Handling
by Illuminatus (Curate) on Oct 05, 2012 at 21:07 UTC | |
by ashes3d (Initiate) on Oct 05, 2012 at 23:23 UTC | |
by kcott (Archbishop) on Oct 06, 2012 at 07:36 UTC | |
by ashes3d (Initiate) on Oct 06, 2012 at 09:03 UTC | |
|
Re: PERL Binary Data Handling
by Anonymous Monk on Oct 05, 2012 at 20:55 UTC |