Bits and Pieces

You can work with an array of bits (a bitstring) with the vec operator, setting bit number 123, clearing bit number 456, and checking the state of bit 789. Bitstrings may be of arbitrary size. The vec operator can work with chunks of other sizes as long as the size is a small power of two, so it’s useful if you need to view a string as a compact array of nybbles. See the perlfunc manpage.

Get Learning Perl, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.