in reply to output binary data

Allasso:

You can use the pack function to create a binary value in a scalar variable, and then write it to the output file. Be sure to use binmode on the file handle so that it won't modify the binary values you send. Something like:

use strict; use warnings; my $foo = 12345; $foo = pack "l", $foo; open my $FH, '>', "foo.bin"; binmode($FH); print $FH $foo; close $FH;

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: output binary data
by morgon (Priest) on Dec 29, 2010 at 07:32 UTC
    You probably are aware of this but "32-bit integer" could mean different things.

    It could be either signed or unsigned or you may want (for networking purposes) use a different endianess (is that a word?) than the one your architecture uses.

    Happily pack provides "l", "L", ,"N", and "V" to cater for all your needs as long as you know what you need.