I've got a problem with something I'm currently working on. All that I have needed to use perl for up until now was some pretty basic text manipulating. Nothing too fancy, with the help of some of the monks here, I was able to come out of it great, learning a lot. Now, there is a new problem.
I've got a file that is pretty much raw binary data, and an old solution with a ksh script under unix that did this:
cc=`hd -bx -s 29 -n 3 <"$filename"|tr -d '[ " " ]'|awk '{print $2}'`
In some parts, there is an offset as well, which I understand how to work with. The problem I'm hitting is that I do not know how to emulate this in perl.
The HD command on our old Unix machine was set like this:
hd-- display files in a hexadecimal format
hd [ -format (bx is binary)] [ -s(offset)] [-n (count)] [filename]
tr - translate characters
the -d Deletes all input characters in the input string.
I found this module that had something similar to what I'm trying to do, but I don't understand how to use it.
Any help is much appreciated.
How do I convert between decimal and binary?
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.