in reply to Constructing 32-bit hexadecimal integers

I've tried packing and unpacking every way I know how ...

Last night, I was hacking, packing and unpacking because my understanding of those operations was lacking.

I hope that you will find my examples below of some help.
Bonus question: is my machine big-endian or little-endian?

Rudif

#! perl -w use strict; my $string = uc " hack && pack || unpack"; #my $string = 'abcdefgh'; #my $string = uc 'abcdefgh'; #my $string = 'ABCD'; my @hex = unpack 'H*', $string; print "H @hex\n"; my @bytes = unpack 'C*', $string; print "C @bytes\n"; my @revbytes = reverse @bytes; my $revbytes = pack 'C*', @revbytes; print "C $revbytes\n"; my @shorts = unpack 'S*', $string; print "S @shorts\n"; my @revshorts = reverse @shorts; my $revshorts = pack 'S*', @revshorts; print "S $revshorts\n"; my @longs = unpack 'L*', $string; print "L @longs\n"; my @revlongs = reverse @longs; my $revlongs = pack 'L*', @revlongs; print "L $revlongs\n"; my @bits = unpack 'B*', $string; print "B @bits\n"; my @revbits = reverse @bits; my $revbits = pack 'B*', @revbits; print "B $revbits\n"; ++$_ foreach @bytes; my $bytes = pack 'C*', @bytes; print "C $bytes\n"; __END__ H 204841434b202626205041434b207c7c20554e5041434b C 32 72 65 67 75 32 38 38 32 80 65 67 75 32 124 124 32 85 78 80 65 6 +7 75 C KCAPNU || KCAP && KCAH S 18464 17217 8267 9766 20512 17217 8267 31868 21792 20558 17217 S ACNP U||K AC P&&K AC H L 1128351776 640032843 1128353824 2088509515 1347310880 L UNPK || PACK && HAC B 001000000100100001000001010000110100101100100000001001100010011000 +100000010100000100000101000011010010110010000001111100011111000010000 +0010101010100111001010000010000010100001101001011 B HACK && PACK || UNPACK C !IBDL!''!QBDL!}}!VOQBDL