'd' or 'D'
These are C double and long double, respectively. They are probably different. On Intel machines, long double is usually an 80-bit non-IEEE754 type while double is standard IEEE-754 double precision type.

'f' and 'F'
These are C float and "whatever Perl uses internally". Again, on Intel machines float usually represents IEEE-754 single precision type, while NV would be even less portable than long double (because a user could rebuild their Perl with different definition for NV) but priceless for exact data caching in between the runs of your own application.

To answer your original question, use f for IEEE-754 single precision, d for IEEE-754 double precision types compatible with C and VB (if float and double do not correspond to IEEE types on a given system, chances are it doesn't support IEEE types at all and such processors are rare enough that you probably shouldn't worry about them) and > for big-endian (most significant byte first; "network byte order"), < for little-endian (least significant byte first; "Intel byte order"). Also, you were right, to sequentially append to binary files, just use open (my $fh, ">>:raw", $filename);.


In reply to Re^2: Perl binary file by Anonymous Monk
in thread Perl binary file by kepler

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.