Hi Gunnar,

if I understand well, it is extremely difficult to make CGI.pm produce
valid html

My problem are the many <p /> tags in the form - and the checked
instead of checked="checked" in the input-tags. But probably I am not
yet understanding CGI.pm?

Probably it is really easier, to print directly avoiding CGI.pm, as
Gunnar suggested?


Greetings to all


marek


My example-script looks now like follows:

#! /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://example.org";;
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};
my $ref = $ENV{HTTP_REFERER};

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

print header;


print start_html(-dtd=>[ '-//W3C//DTD XHTML 1.0 Strict//EN',

        'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd' ],
                 -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"},"http://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 "<br /><br />your Referring Page was: $ref";
print "</p>";

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

if (param()) {
my $name      = param('name');
my $keywords  = join ', ',param('words');
my $color     = param('color');
print p,("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;



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


Reply via email to