Hello all,


I am trying, to understand the Perl module CGI.pm and have two little
questions. First my exercizes:

#! /usr/bin/perl -wT

use strict;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use CGI qw/:standard/;
use Socket;

####my VARS################

my $email     =  "[EMAIL PROTECTED]";
my $url       =  "http://something.com";;
my %colours   = (
              red => "#ff0000",
              green => "#00ff00",
              blue => "#0000ff",
              black => "#000000",
              white => "#ffffff"
              );

my $hostname  = gethostbyaddr(inet_aton($ENV{REMOTE_ADDR}), AF_INET);

my $ua = $ENV{HTTP_USER_AGENT};

####END my VARS#############

print header,

start_html(-title=>'Hello World, Address, Colours',
           -head=>[Link({-rel=>'stylesheet',
                   -href=>'../styles/style.css',
                   -type=>'text/css',
                   -media=>'screen'})
                   ]
                 ),
h1('Hello World!'),
p('And this is a comment to my first Hello World Script!'),

p("My email is $email and my webpage is",
    a({-href=>"$url"},"example.org"));

print "<p>";

foreach my $colour (keys %colours) {
        print qq(<span style="class:time1; color:$colours{$colour}">$colour</
span><br />\n);
    }
print "</p>";

print p("Welcome, dear Visitor from <em>$hostname</em> !");

print "<p>";

print "Your Browser is: $ua<br /><br />";
if ($ua =~ /MSIE/){
    print "your browser is Internet Explorer!<br /><br />";
} elsif ($ua =~ /Netscape/i){
    print "your browser is Netscape!<br /><br />";
} elsif ($ua =~ /Safari/i){
    print "your browser is Safari! Most likely your Operating System
is Macintosh! Isn't it?<br /><br />";
} elsif ($ua =~ /Opera/i){
    print "your browser is Opera!<br /><br />";
} elsif ($ua =~ /Mozilla/i){
    print "your browser is probably Mozilla!<br /><br />";
} elsif ($ua =~ /Lynx/i){
    print "your browser is probably Lynx!<br /><br />";
} else {
    print "I give up! Don't know which Browser you are using!<br /
><br />";
}

print "</p>";

print hr({-class=>'guest3'}),
start_form,
p("What's your name? ",textfield('name')),
p("What's the combination? ",
checkbox_group(-name=>'words',
                          -values=>['eenie','meenie','minie','moe'],
                          -defaults=>['eenie','minie'])),
p("What's your favorite color? ",
popup_menu(-name=>'color',
                  -values=>['red','green','blue','chartreuse']),
submit),
end_form,
hr({-class=>'guest3'});

if (param()) {
my $name      = param('name');
my $keywords  = join ', ',param('words');
my $color     = param('color');
print "Your name is ",em(escapeHTML($name)),p,
        "The keywords are: ",em(escapeHTML($keywords)),p,
        "Your favorite color is ",em(escapeHTML($color)),
        hr({-class=>'guest3'});
}

print hr({-class=>'guest3'}),
end_html;

First question: this cgi script inserts an strange DOC-Type, from
which I have never heard off:

<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
        "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd";>

May I force mod_perl to insert an other doc-type? For example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>

Or is this probably the configuration on the server, where I have no
control to insert a strict-xhtml Header?
By the way: I am unable to make a syntax-check with BBEdit (on
Macintosh) with the Basic-Doc type. Is there a Perl module or an other
way, to check the syntax of this xhtml doc-type in my Shell?

I am trying to produce valid html. And my next question concerns the
form-syntax. My cgi script produces the following:

<form method="post" action="/cgi-bin/first.cgi" enctype="application/x-
www-form-urlencoded">
        <p>
                What's your name? <input type="text" name="name" />
        </p>
        <p>
                What's the combination? <input type="checkbox" name="words"
value="eenie" checked />eenie <input type="checkbox" name="words"
value="meenie" />meenie <input type="checkbox" name="words"
value="minie" checked />minie <input type="checkbox" name="words"
value="moe" />moe
        </p>
        <p>
                What's your favorite color? <select name="color">
                        <option value="red">
                                red
                        </option>
                        <option value="green">
                                green
                        </option>
                        <option value="blue">
                                blue
                        </option>
                        <option value="chartreuse">
                                chartreuse
                        </option>
                </select> <input type="submit" name=".submit" />
        </p>
        <input type="hidden" name=".cgifields" value="words" />
</form>

Under xhtml-sctrict should be inserted: checked="checked"! How to
achieve this?


thank you for your patience

marek


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to