No need to mask off individual bits (though you can do that if you really need to using & and >> -- see perlop for more on these operators).
Try reading the documentation for sprintf (and search for the word binary). You should find that it has all the power you need!
Update: You may prefer the nearly identical printf for your purposes.
In reply to Re: Bitwise operators
by liverpole
in thread Bitwise operators
by thevoid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |