#!/usr/bin/env perl
use warnings;
use 5.012;
my $var = 1 << 31;
say unpack( "B*", pack( "N", $var ) );
# 10000000000000000000000000000000
如何从
打包/解压缩my $var = 1 << 63;
这样的输出?
# 1000000000000000000000000000000000000000000000000000000000000000
答案 0 :(得分:5)
say unpack("B*", pack( "Q>", $var ));
>
强制Q
(无符号64位“quad”)类型上的big-endian字节顺序。