if your file contains only binary data, why is it a text file? you can vastly compress it by using one bit per bit instead of one byte per bit. use vec and binmode. for a more friendly interface, you can tie your bit vector to an array with Tie::VecArray