But that is a different number :)
https://metacpan.org/pod/perlfunc#pack says
The integer formats s, S, i, I, l, L, j, and J ... For example, a 4-byte integer 0x12345678 (305419896 decimal) would be +ordered natively (arranged in and handled by the CPU registers) into +bytes as 0x12 0x34 0x56 0x78 # big-endian 0x78 0x56 0x34 0x12 # little-endian
So I type
Which seems to agree with above and N An unsigned long (32-bit) in "network" (big-endian) order.$ perl -V:byteorder byteorder='1234'; $ perl -e"print 0x12345678 " 305419896 $ perl -e"print unpack q{H*}, pack q{N*}, 0x12345678 " 12345678 $ perl -e"print unpack q{H*}, pack q{N*}, 305419896 " 12345678 $ perl -e"print sprintf q{%x}, 305419896 " 12345678
N packs 305419896 correctly as big-endian, and my machine is big endian (as sprintf shows)
In reply to Re: Is the documentation for Perl 5.20 'pack' correct?
by Anonymous Monk
in thread Is the documentation for Perl 5.20 'pack' correct?
by flexvault
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |