in reply to Bytes to bits

I think that the answer to your question is easier than you think. $result is in the 0's and 1's format you desire already. The question, then, is how to manipulate that data!

Are you familiar with masks? If not, then you need to read more about binary math. If you are familiar with masks, then the following will be straightforward. Suppose you want to find out whether the value in the 4th position from the right is set and then do something like set the value in the second position from the right. The code to do this in PERL is below:

my $mask=1<<3; # Take 1 and shift it three positions left # The parens below are NECESSARY due to binding if (($result & $mask) == $mask) { my $new_mask=1<<1; $ Move 1 to the second position $result |= $new_mask; }

I hope this answers your question!