5

Similar to how you can use pack's:

N  An unsigned long (32-bit) in "network" (big-endian) order.

Is there any method for packing a 64-bit integer in "network" (big-endian) order in Perl?

GoldenNewby
  • 4,382
  • 8
  • 33
  • 44

1 Answers1

5

If your system supports the Q pack format, you can use Q> to get big-endian (since Perl 5.9.2):

% perl -e 'print pack("Q>", 1)' | hexdump -C
00000000  00 00 00 00 00 00 00 01                           |........|
Alnitak
  • 334,560
  • 70
  • 407
  • 495