On Jul 9, Derrick Jamison said:
>I am working on a script to move some data between databases and ran into a
>problem. Basically I need to convert a field from big-endian to
>little-endian before I move the data. I have been doing some digging trying
>to see if there is a function available for this, but I haven't found a
>clear, definitive answer. Can anyone help me with this?
>From 'perldoc -f pack':
$foo = pack("s2",1,2);
# "\1\0\2\0" on little-endian
# "\0\1\0\2" on big-endian
So...
use constant IS_BIG_ENDIAN => pack('s', 1) eq "\0\1";
use constant IS_LITTLE_ENDIAN => pack('s', 1) eq "\1\0";
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **