in reply to uploading images into cgi's

Other people mentioned setting the Content-Type to image/gif or whatever it should be. I don't see where you are opening the file. You should explicity open the file instead of using the implicit filehandle. Your regexp doesn't do anything since you don't use $1. If you are going to parse the path, use File::Basename.

I will mention that you shouldn't read the binary file like it is a text file. You definitely should set binmode on the filehandle, otherwise you will run into problems if you ever run the program on a machine with different line endings.

You also shouldn't read the binary file by lines. Either slurp the whole file into a scalar in if you know they won't be too large.

my $data = do { local $/ = undef; <$image_fh>; };

Or read and write the file by blocks:

while (read($image_fh, $buffer, 4096)) { print $buffer; }