in reply to Creating a binary file problem
It's not entirely clear to me what exactly you want to be written to the file, but in case you want to print the values expressed in the hex strings (such as "0x0000001b") as binary values to the file, you could say
my $hex = "0x0000001b"; print BIN pack('H*', substr($hex,2));
This would also work for values larger than a Perl number could hold. In the example above, it would write 4 bytes / 32 bits.
On a side note, don't use printf, unless you actually specify a format string.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creating a binary file problem
by ikegami (Patriarch) on Apr 05, 2012 at 20:46 UTC |