S
Shashank Khanvilkar
Hi,
All help is appreciated.
I have to read a binary file having a given structure (not important here).
One field that i need to read is a 4 byte field specifying some page
numeber.
If i want to display this page number, how can u do this?
The below fragment does not seem to work,
--SNIP--
read(IN, $buffer, 4); #IN is the fh for a file open in binary mode..
$page_number = ord($buffer);
print "[XXX] $page_number\n";
--SNIP--
For example, if $buffer contains the following four values,
0x74 0x29 0x00 0x00
then
print will print
[XXX] 116
which is dec(0x74)while I want dec(0x74|0x29|0x00|0x00);
(do not worry about the endianess at this point.)
Thanks
Shank
All help is appreciated.
I have to read a binary file having a given structure (not important here).
One field that i need to read is a 4 byte field specifying some page
numeber.
If i want to display this page number, how can u do this?
The below fragment does not seem to work,
--SNIP--
read(IN, $buffer, 4); #IN is the fh for a file open in binary mode..
$page_number = ord($buffer);
print "[XXX] $page_number\n";
--SNIP--
For example, if $buffer contains the following four values,
0x74 0x29 0x00 0x00
then
print will print
[XXX] 116
which is dec(0x74)while I want dec(0x74|0x29|0x00|0x00);
(do not worry about the endianess at this point.)
Thanks
Shank