Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

64 Bit "network" (big-endian) order Integer in Perl

Tags:

perl

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?

like image 323
GoldenNewby Avatar asked May 14 '12 08:05

GoldenNewby


1 Answers

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                           |........|
like image 101
Alnitak Avatar answered Sep 23 '22 00:09

Alnitak