使用perl查找系统是小端还是大端 [英] Finding if the system is little endian or big endian with perl

查看:47
本文介绍了使用perl查找系统是小端还是大端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Perl查找我的系统是小端字节顺序还是大端字节顺序?

Is there an option to find if my system is little endian byte order or big endian byte order using Perl?

推荐答案

perl -MConfig -e 'print "$Config{byteorder}\n";'

请参见 Perl文档

如果输出字符串的第一个字节为1,则可以(具有中等安全性)假定它是低位字节序。如果是4或8,则可以采用big-endian。

If the first byte of the output string is 1, you can assume (with moderate safety) that it is little-endian. If it is 4 or 8, you can assume big-endian.

这篇关于使用perl查找系统是小端还是大端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆