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