A
Adam Schneider
Here's a completely hypothetical example:
I have a binary file containing one byte: hex 65, or "e" in text. I
can get perl to read it and tell me that this is "01100101" in binary.
But hidden in here are two pieces of information: the first 5 bytes are
a number ranging from 0 to 32 and the last 3 bytes are another number
between 0 and 8. I need those two decimal numbers (in this case, 12
and 5) put into two variables.
I have read all the documentation on "pack," "unpack," "vec," bitwise
operators, and everything else, and I still have no idea how to extract
a few bits out of a longer string of bytes. The help files all seem to
have been written with the assumption that I majored in computer
science and learned how to program years ago in some pre-Perl language
-- which I did not.
Can someone please pass along a simple solution that will make sense to
someone who doesn't know the hardcore geeky stuff? I know it's out
there, I just can't find it. (The closest I came was "vec," but it
doesn't let you ask for chunks that aren't powers of 2.)
Thanks in advance,
Adam Schneider
Portland, OR
I have a binary file containing one byte: hex 65, or "e" in text. I
can get perl to read it and tell me that this is "01100101" in binary.
But hidden in here are two pieces of information: the first 5 bytes are
a number ranging from 0 to 32 and the last 3 bytes are another number
between 0 and 8. I need those two decimal numbers (in this case, 12
and 5) put into two variables.
I have read all the documentation on "pack," "unpack," "vec," bitwise
operators, and everything else, and I still have no idea how to extract
a few bits out of a longer string of bytes. The help files all seem to
have been written with the assumption that I majored in computer
science and learned how to program years ago in some pre-Perl language
-- which I did not.
Can someone please pass along a simple solution that will make sense to
someone who doesn't know the hardcore geeky stuff? I know it's out
there, I just can't find it. (The closest I came was "vec," but it
doesn't let you ask for chunks that aren't powers of 2.)
Thanks in advance,
Adam Schneider
Portland, OR