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

Hello. I have this three files. say_hello.cgi
use Modules::Parse ('start_parser'); use strict; my @resp = start_parser(); print @resp;
Parse.pm
package Modules::Parse; use Exporter; @ISA = ('Exporter'); @EXPORT_OK = ('start_parser'); use strict; use CGI; use CGI::Carp qw(fatalsToBrowser set_message); use CGI::Pretty qw(:standard); #My Modules use Modules::Htmlpage; sub start_parser { my @resp = (); if (!param()){ push @resp, &Modules::Htmlpage::make_header("Hello first page."); push @resp, &Modules::Htmlpage::make_first_page(); push @resp, param(); } elsif (param('get_in')){ push @resp, &Modules::Htmlpage::make_header("I say hello to you.") +; push @resp, &Modules::Htmlpage::make_top_content("home"); push @resp, param(); } else{ push @resp, Modules::Htmlpage::make_header("There are params but n +ot get_in."); push @resp, Modules::Htmlpage::make_top_content("home"); push @resp, param(); } push @resp, end_html; return @resp; } 1;
Htmlpage.pm
package Modules::Htmlpage; use Exporter; @ISA = ('Exporter'); @EXPORT_OK = ('make_header', 'make_first_page', 'make_top_content'); use strict; use CGI::Carp qw(fatalsToBrowser set_message); use CGI::Pretty qw(:standard); my $path = '../images/mimgarea'; sub make_first_page { my @resp = (); push @resp, start_form, #method: POST # action: this script # enctype: application/x-www-form-urlencoded table( {-border=>'0', -width => '950' , -align=>'center', -cellspac +ing=>"0", -cellpadding=>"0",}, Tr( td( {-align=>'center',-width=>"50%"}, image_button( { -name => "get_in", -title => "Enter hello", -alt => 'ENTER', -value=> "ENTER", -src=>"$path/hello.gif"}, ), ), ), ), endform; return @resp; } sub make_header{ my @resp = (); my $title = shift; my $descript = "Hello page description."; push @resp, header, start_html( { -title => $title, -meta => { 'keywords' => 'Hello, blabla', 'description' => "$descript" ,}, } , ); return (@resp); } sub make_top_content { my $come_from = shift; my @resp = (); push @resp, table ({ -class=>'top', -width=> '950', -border=> "0", + -cellpadding=> "0", -cellspacing=> "0", -align=> "center"}, Tr ( td ('Inside hello page.\n'),), ); return (@resp); } 1;
In Mozilla firefox, beonex,netscape ok. Internet explorer 6.0 says
Internal Server Error The server encountered an internal error or misconfiguration and was u +nable to complete your request. Please contact the server administrator, admin@yourhost.com and inform + them of the time the error occurred, and anything you might have don +e that may have caused the error. More information about this error may be available in the server error + log. ---------------------------------------------------------------------- +---------- Apache/2.0.48 (Win32) mod_perl/1.99_12 Perl/v5.8.3 Server at localhost + Port 80
Can you help me? I think that related to...
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-U +S">

The xml:lang attribute of the HTML tag is not supported. Netscape Navigator 4.0, Netscape Navigator 6.0, Microsoft Internet Explorer 5.0, Microsoft Internet Explorer 5.5, Microsoft Internet Explorer 6.0

The xmlns attribute of the HTML tag is not supported, but it has no detrimental effect. Netscape Navigator 4.0, Netscape Navigator 6.0

The Lang attribute of the HTML tag is not supported. Netscape Navigator 4.0 , Netscape Navigator 6.0

Thanks, that is all that i can find bad in my prog. ;) Any suggestion to do a better code?

Thanks for your time.

Replies are listed 'Best First'.
Re: Problem with internet explorer.Mozilla firefox,beonex,netscape ok.
by tlm (Prior) on Mar 27, 2005 at 16:48 UTC

    More information about this error may be available in the server error log.

    Have you looked at the server error log? What does it say?

    the lowliest monk

Re: Problem with internet explorer.Mozilla firefox,beonex,netscape ok.
by CountZero (Bishop) on Mar 27, 2005 at 20:04 UTC
    If there is to be any difference between IE and the other browsers, it must be in the way they return the parameters to your server.

    The server doesn't care which type of browser is "listening", so you should try to find out what gets returned to the server by your form.

    Best way to do that is to set the "action" field in your form to another script that simply does a Data::Dumper of your CGI-object and see if your get a different return from IE and the other browsers.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Problem with internet explorer.Mozilla firefox,beonex,netscape ok.
by nobull (Friar) on Mar 27, 2005 at 16:51 UTC
    BEGIN { unshift @INC, "./Modules"; }

    What do you think is the purpose of this? (I suspect it has none).

    More information about this error may be available in the server error log.

    Well was it?

      BEGIN { unshift @INC, "./Modules"; }

      What do you think is the purpose of this? (I suspect it has none).

      It's roughly the equivalent of

      use lib './Modules';

      It's quite common for times when you're on a multi-user system, and you don't have access to install modules in the main include directories. See perldoc lib for more information.

      I think it was for have access to the directory... wrong... doesn't needed :) thanks server error log says...

      malformed header from script. Bad header=</body></html>: say_hello.cgi, referer: http://localhost/cgi-bin/say_hello.cgi

        sub start_parser { my @resp = (); if (!param()){ push @resp, &Modules::Htmlpage::make_header("Hello first page."); push @resp, &Modules::Htmlpage::make_first_page(); } elsif (param('get_in')){ push @resp, &Modules::Htmlpage::make_header("I say hello to you.") +; push @resp, &Modules::Htmlpage::make_top_content("home"); } push @resp, end_html; return @resp; }

        If param() is true (i.e. there are parameters in the HTTP request) and param('get_in') is false (i.e. there isn't a get_in parameter or is was '' or '0') then start_parser() will just return '</body></html>'.

        Fix it so that it returns an appropriate valid CGI response under these circumstances.

        BTW: Do you know what the special &-prefixed subroutine call syntax does? If not then don't use it. If so, why you think you need it?

        Update: Fixed spurious ! typo.

Re: Problem with internet explorer.Mozilla firefox,beonex,netscape ok.
by Anonymous Monk on Mar 27, 2005 at 19:21 UTC
Re: Problem with internet explorer.Mozilla firefox,beonex,netscape ok.
by Pescador (Novice) on Mar 27, 2005 at 17:15 UTC

    I think it was for have access to the directory... wrong... doesn't needed :) thanks server error log says...

    malformed header from script. Bad header=</body></html>: say_hello.cgi, referer: http://localhost/cgi-bin/say_hello.cgi

      It looks like your code is generating some malformed HTML. Try running your code directly from the command line, and see what is it that it is printing to STDOUT. Do you have an extra set of </body></html> tags at the end?

      the lowliest monk

        No extra set </body></html>
Re: Problem with internet explorer.Mozilla firefox,beonex,netscape ok.
by Anonymous Monk on Mar 28, 2005 at 00:25 UTC
    HTTP is not HTML. Malformed header errors refer to HTTP.
Re: Problem with internet explorer.Mozilla firefox,beonex,netscape ok.
by Pescador (Novice) on Mar 27, 2005 at 17:51 UTC
    I add     push @resp, param(); and
    } else{ push @resp, Modules::Htmlpage::make_header("There are params but n +ot get_in."); push @resp, Modules::Htmlpage::make_top_content("home"); push @resp, param(); }
    In Mozilla output is ...

    Inside hello page.

    get_in.xget_in.yget_in

    internet explorer is ...

    Inside hello page.

    get_in.xget_in.y

    get_in out !!!!!!! Why? Thanks for your help :)