Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    16

    Unanswered: Help required with perl

    While running Perl programs I frequently face following error message
    When I try to run it from browser. as http://localhost/cgi-bin/loan.pl

    Server error!

    The server encountered an internal error and was unable to complete your request.

    Error message:
    Premature end of script headers: loan.pl

    If you think this is a server error, please contact the webmaster

    Error 500

    localhost
    Wed 07 Apr 2004 11:42:44 AM IST
    Apache/2.0.40 (Red Hat Linux)

    When I view the error log then their I always get common error message i.e
    Premature end of script headers: loan.pl

    Here point to be noted is that I can run the same program from terminal without any error messages. I tried -wc option as well. And it told me .syntax ok.

    Also I have added proper content-type header in my program.
    Permission for file is set to 755.

    Any body have a clue why this happens ?
    what exactly premature end of script header means ?
    From where I can see description of this error message ?

    Regards
    Amit

  2. #2
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    167
    maybe you want to print something before you print the header...

    Please post some code!
    board.perl-community.de - The German Perl-Community

  3. #3
    Join Date
    Mar 2004
    Posts
    16
    Originally posted by reneeb
    maybe you want to print something before you print the header...

    Please post some code!
    Here is the code.

    #!/usr/bin/perl
    #use strict;
    use CGI::Carp qw(fatalsToBrowser);
    print "Content-type: text/html \n\n";
    # Script: vegetables3.pl
    use CGI::Pretty qw/:standard :html3/;

    print header,
    start_html('Vegetables'),
    h1('Vegetables are for the Strong'),
    table({-border=>undef},
    caption(strong('When Should You Eat Your Vegetables?')),
    Tr({-align=>CENTER,-valign=>TOP},
    [
    th(['','Breakfast','Lunch','Dinner']),
    th('Tomatoes').td(['no','yes','yes']),
    th('Broccoli').td(['no','no','yes']),
    th('Onions').td(['yes','yes','yes'])
    ]
    )
    ),
    end_html;



    Regards
    amit

  4. #4
    Join Date
    Oct 2003
    Location
    Slovakia
    Posts
    482

    Re: Help required with perl

    Originally posted by amit_28oct
    While running Perl programs I frequently face following error message
    When I try to run it from browser. as http://localhost/cgi-bin/loan.pl

    Server error!

    The server encountered an internal error and was unable to complete your request.

    Error message:
    Premature end of script headers: loan.pl

    If you think this is a server error, please contact the webmaster

    Error 500

    localhost
    Wed 07 Apr 2004 11:42:44 AM IST
    Apache/2.0.40 (Red Hat Linux)

    When I view the error log then their I always get common error message i.e
    Premature end of script headers: loan.pl

    Here point to be noted is that I can run the same program from terminal without any error messages. I tried -wc option as well. And it told me .syntax ok.

    Also I have added proper content-type header in my program.
    Permission for file is set to 755.

    Any body have a clue why this happens ?
    what exactly premature end of script header means ?
    From where I can see description of this error message ?

    Regards
    Amit
    Do you have mod_perl isntalled and properly configured in your apache apache server? Error 500 is Internal server error which is caused usually by bad configuration of Apache.

  5. #5
    Join Date
    Jan 2004
    Location
    Germany
    Posts
    167
    you are printing a header twice, you just need one.

    delete the space behind "html" in this line:
    print "Content-type: text/html \n\n";

    It must be:
    print "Content-type: text/html\n\n";


    @ika: An error 500 can be caused by many things, but not only by misconfiguration. If a variable isn't declared in a correct way, you get an error 500.
    Most times an error 500 is caused by misspellings or syntax errors in the script.
    board.perl-community.de - The German Perl-Community

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •