Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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?


Comment on Re: How to easily convert the pack function from little endian to big endian
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://986705]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2014-12-29 14:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (188 votes), past polls