Perl: the Markov chain saw | |
PerlMonks |
Re: How to easily convert the pack function from little endian to big endianby flexvault (Monsignor) |
on Aug 10, 2012 at 14:19 UTC ( [id://986757]=note: print w/replies, xml ) | Need Help?? |
Welcome semiconPERL, I'm going to guess that your problem is more about transferring data from big to little endian and vice-versa. One method I use is to convert the data to printable hex which is in network order. See the below code (tested): I verified on both little/bin endian machines that the file created is exactly the same. You can ftp the files back and forth and all information will be in network order. You can process the data in 4 characters (16 bits), 8 characters (32 bits), or 16 characters (64 bits) by using the 'substr' function on the the beginning of the data: If you need to have variable data, then use a separator between variables in the data. I usually use 'chr(254)' as a separator since my editor shows it as a special character, but you can use any non-printable character. Then use 'split' to separate the variables. Good Luck "Well done is better than well said." - Benjamin Franklin
In Section
Seekers of Perl Wisdom
|
|