Liam has asked for the wisdom of the Perl Monks concerning the following question:

Here is a script:
#!/usr/bin/perl use CGI qw(param); print <<END_of_Start; content-type: text/html <HTML> <head> <title>Hello world</title> </head> <body> <h1>Greetings Terrans</h1> END_of_Start my $favourite = param("flavour"); print "<p>Your favourite flavour is $favourite"; print <<All_Done; </body> </html> All_Done
i upload that onto my CGi-bin on tripod, but when i try to run it, it just gives me error messages!! why the hell doesnt it work??

Replies are listed 'Best First'.
RE: Why doesnt it work
by chromatic (Archbishop) on Mar 25, 2000 at 23:59 UTC
    Well, the first thing you need to change is the content type line: print "Content-type: text/html\n\n"; is what most people usually use. It can be tricky to get that just right in a here-doc, so I never do it that way. You could also use the header method in CGI, which will take care of it in a platform-independent fashion. That's the biggest and best reason for errors I can see.
Re: Why doesnt it work
by chromatic (Archbishop) on Mar 24, 2000 at 21:07 UTC
    Can you run it from the command line? If you haven't yet done so, get the ActiveState compiler -- using the CGI module, you can run your scripts from the command line and simulate working in a browser environment.

    I suspect you probably want to do something like: print "Content-type: text/html\n\n"; before you print anything else to the browser, as you'll definitely get the "500 Internal Error message" without it. The appropriate subroutine in CGI.pm is header(). If that fails, see My CGI script runs from the command line but not the browser. (500 Server Error).

      thanks. But it still doesn't seem to work. I got O'reilly's Learning Perl book, and thats the code it tells me on the chapter to do with CGI. anyone know where i can find a place to tell me how to turn my Perl into CGI, so i can write forms,etc
RE: Why doesnt it work
by setantae (Scribe) on Mar 25, 2000 at 02:05 UTC
RE: Why doesnt it work
by Anonymous Monk on Mar 25, 2000 at 22:38 UTC
    Be careful for those <<END... print statements. I noticed that sometimes programmers will add some whitespace without noticing, i.e.,
    print <<end_of_stuff; [..some stuff..] end_of_stuff
    That second 'end_of_stuff' screws up because of the prefixed space. Also, you probably check this already, but did you convert you're line endings to Unix style and verify that your ftp program didn't make any changes? I once had a friend who couldn't get his scripts to work and then we discovered his ftp client kept adding /r to the end of each line.
RE: Why doesnt it work
by Anonymous Monk on Mar 26, 2000 at 03:28 UTC
    You will need to use the Tripod Modules. They are in the module directory. They are different I think. Use their's.
RE: Why doesnt it work
by zak (Initiate) on Mar 28, 2000 at 08:47 UTC
    I'm pretty sure you need to capitalise the 'C' of 'Content-type'. Otherwise perhaps try and tail the error logs if you can? (I'm not sure how Tripod works in that regard). Hope that helps