Please note that if you are on Win32, you will need to call binmode on a file handle before reading, if its data is binary.
view this file's source