PERL Newbie. Also, binary newbie. I need to access a binary data file (stdf, standard test data format, http://etidweb.tamu.edu/cdrom0/image/stdf/spec.pdf). How do I even begin? Can someone explain to me how to access such a file, then extract the data to a form that is readable?
I've seen the article with the following code:
$gifname = "picture.gif";
open(GIF, $gifname) or die "can't open $gifname: $!";
binmode(GIF); # now DOS won't mangle binary input from G
+IF
binmode(STDOUT); # now DOS won't mangle binary output to ST
+DOUT
while (read(GIF, $buff, 8 * 2**10)) {
print STDOUT $buff;
}
What is the "8 * 2**10" doing?
I am working with SunOS 5.8 if that matters.
Thanks.
mnj200g
Edit: g0n - code tags
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.