I expected a text file that I can understand.
You've explicitly asked perl convert each byte to a number, so you're expectations were naive.
A quick look on the web turns up this page which identifies:
- The first four bytes are the signature: '.sff';
Which you have.
- The next four byte form an unsigned 32-nit integer that is the version: Apparently always 1.
Which you have.
- The "index offset" and "index length", which it doesn't state the size, but from the example, the offset must be at least 4 bytes and the index at least two. Either or both could also easily be 8 bytes. Especially the offset.
You have 14 zeros; which perhaps means your file doesn't contain an index.
- Lots more fields.
You haven't shown us the data.
The point of that was to make it clear that you cannot "convert binary to text" unless you understand what the binary is.
That means you need to know:
- what fields the file contains;
- in what order;
- and in what binary format they are stored;
And that is true regardless of whether you read the file using Perl, C, or any other language.
As an aside, I'd bet that -- given the information required -- a Perl script can decode one of these files just as quickly (within a few percent) as a program written in C.
And it would be a whole heap faster to write the Perl version. (Admittedly, this is the type of thing I've been doing week in, week out for a decade or more. :)
(Also, if you post a link to a file in this format, I might have a go at decoding it. I've been sitting here waiting for a simulation to complete for 3 days now, and I'm a little bored.)
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
In the absence of evidence, opinion is indistinguishable from prejudice.
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.