As I understand the OP...
The two byte binary data sequence 45d2 (specificaly qq{\x45\xd2}) would unpack with the 'v' specifier as the hex number 0xD245.
>perl -wMstrict -le "my $bin = qq{\x45\xd2}; printf qq{0x%04X \n}, unpack 'v', $bin; " 0xD245
With the first code example of the OP, the eight byte binary data sequence 45d2ff76893a0033 (or qq{\x45\xd2\xff\x76\x89\x3a\x00\x33}) would unpack as
0xD245 0x76FF 0x3A89 0x3300.
>perl -wMstrict -le "my $bin = qq{\x45\xd2\xff\x76\x89\x3a\x00\x33}; my @data = unpack 'v4', $bin; printf '0x%04X ', $_ for @data; " 0xD245 0x76FF 0x3A89 0x3300
But as I understand it, amigero wants 0x76FF 0xD245 0x3300 0x3A89.
>perl -wMstrict -le "my $bin = qq{\x45\xd2\xff\x76\x89\x3a\x00\x33}; my @data = map reverse(unpack 'v*'), unpack '(a4)*', $bin; printf '0x%04X ', $_ for @data; " 0x76FF 0xD245 0x3300 0x3A89
It's a one-liner, but as far as 'efficiency' goes, the remarks of others are pertinent.
In reply to Re: Word reverse
by AnomalousMonk
in thread Word reverse
by amigero
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |