I have an array of unsigned integers (32 bits) that I want to pack into a binary stream:
my @n = (4,8,15,16,23,42);
my $foo = join('', map(pack('I', $_), @n)); # Ugly, isn't?
$foo should contains this binary stream (depending on the endianness)
0000000 0000 0004 0000 0008 0000 000F 0000 0010
0000010 0000 0017 0000 002A
Then I would like to unpack the binary stream back to an array.
How do I properly do it with Perl and if possible with only built-in modules?
$aand$bare reserved for use insortblocks and it's considered bad practice to use them for anything else.join '', map pack('L', $_), @nums;