Hi - I am opening a socket up from a Mandrake machine (Little Endian) to an HP9000 (Big Endian) and receiving a record out of a KISAM file into a variable.
I then write this variable to disk. KISAM files have a data dictionary which states information about where in the record a field is located and the length it is in bytes.
The data dictionary states that the field I am looking for is binary, starts at byte 2 and is 3 bytes long. The field when unpacked should be a long integer 176385.
If I write the variable containing the record I received to disk and open it in binary editor I get this (just showing the first four bytes):
00000000 00000010 10110001 00000001
I wrote a script in perl to pack 176385 and wrote the resulting variable to disk
$num = pack("L", 176385);
Editing this file in binary editor showed:
00000001 10110001 00000010
I presume that I need to convert my variable from big endian to little endian, do a substr($record,2,3) to get the 3 bytes from start byte 2 (as the data dictionary states) and then unpack the resulting string.
How do I convert my variable from big endian to little endian in perl?
PS Im not being tight - I only have 75 points to offer!