in reply to Image content help

The second CGI is wrong. It reads only the first line of the image. You'll have to binmode the file., and read the whole, not just one line. (Update: /me was stupid here.)

Update: also you'll have to chdir to the correct directory if you open the file with a relative path.

Replies are listed 'Best First'.
Re^2: Image content help
by calin (Deacon) on Jun 17, 2004 at 16:05 UTC
    It reads only the first line of the image.

    This is not true. In the code line:

    print <IMG>;

    <IMG> is in list context. It should produce all the "lines" (by whatever definition of "line" $/ (the input record sepatator) gives - default separator is \n), then print should print all those elements joined by $, (the output field separator - by default undefined), followed by the content of $\ (the output record separator - also by default undefined).

Re^2: Image content help
by Anonymous Monk on Jun 17, 2004 at 07:12 UTC
    I changed the second code to
    #!c:/perl/bin/perl print "Content-type: image/gif\n\n"; open(IMG, "packplan.gif"); binmode(IMG); my @file = <IMG>; close(IMG); foreach my $line (@file){ print $line; }
    still no go. This is my first time to try this image thing and I am lost. All the help you are giving me is appreciated.
      You forgot to binmode STDOUT.

      MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
      I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
      ** The third rule of perl club is a statement of fact: pod is sexy.

      Again, either use an absolute path in the open, or else chdir to the correct directory.