Efficient pre-perl-5.10 equivalent of pack(“Q>”)

柔情痞子 提交于 2019-12-04 15:47:55

The Q pattern was introduced in perl 5.6. Your real problem may be that you are trying to use it in a perl compiled without 64bit support.

Anyway, you can use Math::Int64.

Update, an example:

use Math::Int64 qw(int64_to_native);
my $packed = join '', map int64_to_native($_), @ints;

Another option, if you are on a 64bit perl supporting Q but not Q>, is to reorder the bytes yourself:

pack 'C*', reverse unpack 'C*', pack 'Q', $int;
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!