in reply to how to read binary file and give a binary output?

Don't forget binmode and possibly a proper I/O layer .

See:

Maybe also take a look at:

  • Comment on Re: how to read binary file and give a binary output?