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 > first steps wit...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 9 Topic 1416 of 1483
Post > Topic >>

first steps with mod_perl

by mstep@[EMAIL PROTECTED] (Marek) Sep 18, 2007 at 11:46 AM

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




 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 Sun Sep 7 6:54:47 CDT 2008.