Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners Cgi > Re: first steps...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 9 Topic 1416 of 1496
Post > Topic >>

Re: first steps with mod_perl

by mstep@[EMAIL PROTECTED] (Marek) Oct 8, 2007 at 08:04 PM

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     =  "mstep\@[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;
 




 9 Posts in Topic:
first steps with mod_perl
mstep@[EMAIL PROTECTED]   2007-09-18 11:46:19 
Re: first steps with mod_perl
noreply@[EMAIL PROTECTED]  2007-09-19 00:39:30 
Re: first steps with mod_perl
mstep@[EMAIL PROTECTED]   2007-09-22 03:26:05 
Re: first steps with mod_perl
noreply@[EMAIL PROTECTED]  2007-09-23 20:32:19 
Re: first steps with mod_perl
mstep@[EMAIL PROTECTED]   2007-09-30 05:39:09 
Re: first steps with mod_perl
noreply@[EMAIL PROTECTED]  2007-10-06 23:00:21 
Re: first steps with mod_perl
mstep@[EMAIL PROTECTED]   2007-10-08 20:04:40 
Re: first steps with mod_perl
david@[EMAIL PROTECTED]   2007-10-09 11:07:59 
Re: first steps with mod_perl
mstep@[EMAIL PROTECTED]   2007-10-10 08:28:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 10:24:30 CST 2008.