# reading (for example, a gif) local $/ = undef; open FILE, $file; binmode(FILE); # needed for win32 $gif = ; $hexgif = unpack ("H*", $gif); # convert gif to hex string # printing $gif = pack ("H*", $hexgif); # convert hex string back to binary data print "Content-type: image/gif\n\n"; binmode(STDOUT); print $gif;