Support I have some hex raw data printed using c code with format such as “%02X”.
so they look like :
\x00\x20\x00\x10\xfd\x02\x10\x00\x00\x00\x00\x20\xff\x02\x10\x00\x00\x00\x00\x00
\x05\x00\x011\x00\x01\x00\n\x00\x0240
I want to decode them following some format like:
The first two Byte hex “\x00\x20” should be decoded to a ushort:
The following two B hex “\x00\x10” should be decoded to a ushort:
The following 8B hex “\xfd\x02\x10\x00\x00\x00\x00\x20” should be coded to a 64 bit.
The following 8B hex “\xff\x02\x10\x00\x00\x00\x00`\x00” should be coded to a 64 bit;
The following 3 Byte Hex should be decoded to 3 char.
....
How do I implement the decoding in perl
(BTW I do not understand why there are backslash between each hex, is it how hex should be printed out)?