IlyaM is very right with read and pack/unpack. I do tons of binary data work in Perl (actually, have a denied proposal with ORA on it because it was deamed to rarly used :( ), and here are a few things i can add :
  1. use binmode, rarly does portability come so easy
  2. Check and re-check your unpack formats
  3. Try to use the code on the same machine the file is created on (or atleast same kind of machine) to avoid :
  4. Before processing any file, divide the size (-s) by the read size. (Avoid processing 100 Gb of invalid data.)
  5. Make a module of it, that way the pack/unpack are in one place the next time. they suck to re-compute on a cocktail napkin, on a confrence call, from a pub, with a 300 bytes record length, working from an ancient language struct def :/ (not that this happens)

$ perl -e 'do() || ! do() ;' Undefined subroutine &main::try

In reply to Re: Processing Binary Files by MZSanford
in thread Processing Binary Files by regeq

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.