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.
|
|---|