in reply to display gif image

What you have is on the right track, but you might want to take a few other precautions:
#!/usr/bin/perl -w use strict; use CGI::Carp; use CGI; my ($cgi) = new CGI(); my ($gif_name) = 'whatever.gif'; # Or $cgi->parameter('show') my ($image); open (GIF, $gif_name) || die "Could not open $gif_name: $!\n"; binmode (GIF); read (GIF, $image, -s $gif_name); close (GIF); binmode (STDOUT); print $cgi->header("image/gif"); print $image;
Note the use of '-s' to find the complete size of the file, which allows you to read it in one go.

CGI::Carp will allow you to record any run-time errors to the appropriate error_log file, especially those messages generated when you 'die', which normally go sight-unseen.

Update: Added 'binmode(GIF)' as pointed out by dws below, and merlyn as well (Thanks!) No sense in posting 'bad' code.

Replies are listed 'Best First'.
Re: Re: display gif image
by dws (Chancellor) on Apr 27, 2001 at 01:06 UTC
    If you're on Win32, you'll need to add   binmode(GIF); (Ah, merlyn caught this, too.)