7

My original code is in Python, but I need to convert it to Perl for some libraries that I don't have at my disposal in Python.

In Python I would do this:

packet=binascii.unhexlify('F0000000F6905C452001A8C0000000000160994E810FB54E0100DB0000000000000')

AND

This would create a string containing the binary representation of:

0xF0 0x00 0x00 0x00 0xF6 0x90 0x5C 0x45 etc...

Now that my string is a byte array I can send it as the payload for my packet. How do I do it Perl?

ruakh
  • 175,680
  • 26
  • 273
  • 307
Nowayz
  • 1,882
  • 4
  • 21
  • 34

1 Answers1

7

You can use the pack function for this.

Example:

$ perl -e 'print pack("H*", "303132616263"), "\n";'
012abc

Check out the pack tutorial.

Mat
  • 202,337
  • 40
  • 393
  • 406