Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 632
oren Avatar asked Apr 09 '10 20:04

oren


1 Answers

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.

like image 120
Jonathan Leffler Avatar answered Oct 29 '22 10:10

Jonathan Leffler