in reply to display gif image

My guess (since you didn't say) is that you're on ActiveState Perl and you forgot to say binmode on your GIF handle.

But you can avoid even that by using a very efficient file-copy method:

use File::Copy; print "Content-type: image/gif\n\n"; copy "/path/to/gif", \*STDOUT;

-- Randal L. Schwartz, Perl hacker