I have a variable that holds a number:
my $num = 0;
I want to write that number to a file such that 0 (NULL) shows up in the file rather than it's ascii value (0x30 or 48) ... I'm making a binary file, not a text file.
I've tried the following:
open FILE, ">", "test.bin"
printf FILE "%c", $num
printf FILE "%u", $num
printf FILE "%x", $num
But it always shows up as the ascii rather than the actual value.
Can anyone help me?
I would also like to know that this number will always be less than 256, so the value it writes has to go into 1 byte.
Can't use up 4 bytes or anything like that.
Thanks for looking.
my $num = 0;
I want to write that number to a file such that 0 (NULL) shows up in the file rather than it's ascii value (0x30 or 48) ... I'm making a binary file, not a text file.
I've tried the following:
open FILE, ">", "test.bin"
printf FILE "%c", $num
printf FILE "%u", $num
printf FILE "%x", $num
But it always shows up as the ascii rather than the actual value.
Can anyone help me?
I would also like to know that this number will always be less than 256, so the value it writes has to go into 1 byte.
Can't use up 4 bytes or anything like that.
Thanks for looking.