in reply to Re^2: CGI::Carp sometimes fails
in thread CGI::Carp sometimes fails

contains the contents of a JPEG image file.

I suppose one approach to try and narrow it down would be divide and conquer the contents of $file{'receipt', 'file'}. Split it in half and check both halves. Split the bad half again, etc.

You said you tried printing the contents to a file. I assume that was successful?

EDIT: Or instead of divide and conquer maybe try something like:

my $len = length $str; for(my $i = 1; $i <= $len; $i++) { print substr($str, 0, $i) }