Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Bit vectors can save memory by using a single scalar to hold many values. I can use a long string of bits to store the values instead of using an array of scalars. Even the empty scalar takes up some memory; I have to pay for that scalar overhead with every scalar I create. Using Devel::Size, I can look at the size of a scalar:
#!/usr/bin/perl # devel-size.pl use Devel::Size qw(size); my $scalar; print "Size of scalar is " . size( $scalar ) . " bytes\n";