Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How to easily convert the pack function from little endian to big endian

by BrowserUk (Pope)
on Aug 10, 2012 at 09:33 UTC ( #986705=note: print w/replies, xml ) Need Help??


in reply to How to easily convert the pack function from little endian to big endian

Yes:

read EP, $in, 2; $rec_len = unpack ("S>", $in);

But whether that is the right output will depend upon what you got sent.

This would also produce the same output on either type of machine:

read EP, $in, 2; $rec_len = unpack ("S<", $in);

But which of those would produce the correct output, depend entirely on whether the data was packed in little or big-endian order to start with.

And that cannot be determined by the receiver; it can only be assumed.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://986705]
help
Chatterbox?
[LanX]: no idea ... ask py monks! ;-p
[tye]: it turns out that this can be caused by almost anything going wrong. If you want to know what caused the problem, you have to try to load each app by-hand to see what problems it is having, because none of those will be logged.
[tye]: No, I write more Perl than py at work. But I have to deal with plenty of py things.
[tye]: py monks would just be offended.
[Corion]: ;)
[Corion]: Hi tye btw ;)
[Corion]: I found plenty of not chatty enough logs with Perl too ... I'm slowly coming to appreciate Log::Log4perl resp. our homegrown alternative
[tye]: my experience with python so far is more like finding a moderately useful error message is a shocking surprise.
Corion disappears

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2017-09-21 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (252 votes). Check out past polls.

    Notices?