vec
may also be assigned to, in which case parentheses are needed to give the expression the correct precedence as in
vec($image, $max_x * $x + $y, 8) = 3;
Vectors created with vec
can also be manipulated with the
logical operators |, &, and ^, which will assume a bit vector operation
is desired when both operands are strings.
To transform a bit vector into a string or array of 0's and 1's, use these:
$bits = unpack("b*", $vector); @bits = split(//, unpack("b*", $vector));
If you know the exact length in bits, it can be used in place of the *.