in reply to Apache+cgi problem

You're not printing a header:

#!/usr/bin/perl -wT use strict; use CGI qw/ :standard /; my $stats = 'statistics.txt'; open IN_RESULT,"< $stats" or die "Cannot open $stats for reading: $!"; my @in_result = <IN_RESULT>; close (IN_RESULT); my @armyImages = ( '"images/icon_army_dwarf.gif"', '"images/icon_army_empire.gif"', '"images/icon_army_lizard.gif"', '"images/icon_army_orcs.gif"', '"images/icon_army_skaven.gif"' ); print header; print <<WEB_PAGE; . . .

Note that I added the "standard" stuff and made a change or two.

I have to admit, from the names of your images, I'm very curious to see what you're putting together :)

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
Re: (Ovid) Re: Apache+cgi problem
by Dog and Pony (Priest) on Feb 16, 2002 at 15:38 UTC
    Not sure how to say this without sounding as if I am nitpicking an otherwise great post (++), but ah well, I feel bold.

    I just would like to point out that while "Content-type: text/html\n\n" works often, if you are gonna do that instead of useing CGI, you should really end the lines with double "\015\012" instead, like this:print "Content-type: text/html\015\012\015\012";.

    This is more cross-platform, and would work on most machines, except (I think ) VMS and non-ASCII machines. "\015\012" is the defined CRLF sequence for HTTP-headers.

    In reality though, I think that it is just as good to get into the habit of useing the CGI module right away. Just like you say. It takes care of all such concerns. :)

      I can't find the link, but I seem to recall a response from Tom Christiansen to Abigail where he points out that the line endings are typically a non-issue. This is due to this being such a ubiquitous issue that every Web server (that I am aware of) checks the line endings and adjusts them as necessary. Otherwise, the vast majority of scripts ported to another OS could potentially die a horrible death.

      Cheers,
      Ovid

      Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

        I remember the post on clpm too .... I think the point here is that what your program is emitting are CGI headers and not HTTP ones where the line separators should be as described. Indeed the draft CGI/1.2 Specification says :

           The server must translate the header data from the CGI
           header field syntax to the HTTP header field syntax if
           these differ. For example, the character sequence for
           newline (such as Unix's ASCII NL) used by CGI scripts 
           may not be the same as that used by HTTP (ASCII CR
           followed by LF). The server must also resolve any
           conflicts between header fields returned by the script
           and header fields that it would otherwise send itself.
        

        Update: I didn't find the original post to which Ovid referred however i did find This thread in CLPM which has all manner of good stuff in it

        /J\

Re: (Ovid) Re: Apache+cgi problem
by RuneK (Sexton) on Feb 16, 2002 at 15:58 UTC
    Thanks Ovid, The cgi script is now working (after some rework using strict). The program is a warhammer fantasy statistics generator. It's in the beta-beta phase, but can be viewed at: www.skullport.dk/warhammer.htm. The script works but caused me another very strange problem that probably has nothing to do with the cgi script. When viewing "normal" html my images show ok, but the html images generated from the cgi script does not show at all even though the path is the same. Very wierd. Thanks a lot for the help.