Finding if the system is little endian or big endian with perl

后端 未结 2 1389
無奈伤痛
無奈伤痛 2020-12-16 01:05

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

2条回答
  •  佛祖请我去吃肉
    2020-12-16 01:24

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

    See Perl documentation.

    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.

提交回复
热议问题