Dear Monks,
This is my first try at handling a binary file. I have successfully slurped a long string of bits into $trailing:
($id, $trailing) = unpack ("A16 x72 B*", $data);
I now need to divide that string into 8 bits x 4 repeatedly over the string, which may vary from file to file but will always be a multiple of 32. I was wondering how to go about this...
(byte2, byte1, byte4, byte3) = ?????
It is likely trivial but I am stumped!
Thanks for any hints...
Update
Sorry for bothering you, a loop with substr should do it...
substr $trailing, 0, 8, "" ;
Update2
To answer the first question of BrowserUK I read the bits because that filled my variable, it did not occur to me to capture the result in an array !! Many thanks to all!
---jjap
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.