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: