That sets consecutive nybbles (half-bytes) to 0,1,2,3 .. etc.for my $i (0..20) { vec( $bitstring, $offset++, 4 ) = $i ; }
This "unpacks" an ascii string of 4 bytes (the * at the end doesn't do anything since you didn't give a format letter). In other words, it just returns the first 4 bytes of $bitstring without converting them in any way.my $bits = unpack("A4*", $bitstring);
I don't think there's an unpack template for nybbles. If you want to see what you put in $bitstring, you might want to use the bit string template: "b*":
output (broken up for readability):print unpack("b*",$bitstring);
or hex:0000100001001100001010 1001101110000110010101 1101001110110111111100 0010000100110000100000
output:print unpack("h*",$bitstring);
0123456789abcdef012340
In reply to Re: HowTo unpack a vec (bitstring)
by Joost
in thread HowTo unpack a vec (bitstring)
by jeanluca
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |