Re: first steps with mod_perl

2007-10-10 Thread Marek
On 9 Okt., 12:07, [EMAIL PROTECTED] (David Dorward) wrote:
> On 9 Oct 2007, at 04:04, Marek wrote:
>
snip
>
> According to the CGI.pm documentation, it defaults to XHTML (so it  
> should be outputting checked="checked") unless you use -dtd to  
> specify an HTML 2.0 or 3.2 DTD. (Why not HTML 4.x I've no idea). You  
> can also use the -no_xhtml pragma to turn off XHTML generation.
>

Hello David,


thank you for your reply. I found the mistake, which made CGI.pm
produce these lonely  tags. I wrote :

print start_form,
p,("What's your name? ",textfield('name')),
...

instead of :

print start_form,
p("What's your name? ",textfield('name')),
...

see my example my posting before. Only the checked instead of
checked="checked" and selected instead of selected="selected" are
left. Could somebody help me here again and I will stop to bother this
group with my beginners questions ...


greetings


marek



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




Re: first steps with mod_perl

2007-10-09 Thread David Dorward

On 9 Oct 2007, at 04:04, Marek wrote:

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

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


It has been a long while since I tried generating HTML with CGI.pm  
(these days I lean very strongly towards Template-Toolkit), but I'd  
be surprised if it produced  since its either non-Appendix C  
conformant, nonsensical XHTML (a content-less paragraph) or its, in  
HTML, "Start of paragraph followed by a greater than sign" and using  
features marked as badly supported - avoid.


checked rather than checked="checked" is fine in HTML  
(checked="checked" is another of the "avoid this, its badly  
supported" features).


According to the CGI.pm documentation, it defaults to XHTML (so it  
should be outputting checked="checked") unless you use -dtd to  
specify an HTML 2.0 or 3.2 DTD. (Why not HTML 4.x I've no idea). You  
can also use the -no_xhtml pragma to turn off XHTML generation.


Turning off XHTML generation is generally a good thing: http:// 
www.webdevout.net/articles/beware-of-xhtml


... but I'll stick to Template-Toolkit

--
David Dorward
http://dorward.me.uk/
http://blog.dorward.me.uk/



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




Re: first steps with mod_perl

2007-10-09 Thread Marek


Hi Gunnar,

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

My problem are the many  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 => "#ff",
  green => "#00ff00",
  blue => "#ff",
  black => "#00",
  white => "#ff"
  );

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 "";

foreach my $colour (keys %colours) {
print qq(
$colour\n);
}
print "";

print p("Welcome, dear Visitor from $hostname !");

print "";

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

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/




Re: first steps with mod_perl

2007-10-06 Thread Gunnar Hjalmarsson

Marek wrote:

... how to insert the DTD the right way:

print start_html(   -title=>'Secrets of the Pyramids',
-author=>'[EMAIL PROTECTED]',
-base=>'true',
-target=>'_blank',
-meta=>{'keywords'=>'pharaoh secret mummy',
'copyright'=>'copyright 1996 King Tut'},
-style=>{'src'=>'/styles/style1.css'},
-BGCOLOR=>'blue',
-dtd=>[ '-//W3C//DTD XHTML 1.0 Strict//EN',

'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd' ]
);


But the resulting markup does not validate as XHTML 1.0 Strict, does it?
I'm thinking of the 'target' and 'bgcolor' attributes.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




Re: first steps with mod_perl

2007-09-30 Thread Marek

Thank you Gunnar,

I know how to print in Perl! My question was about CGI.pm Module, and
how the default DTD is set: by the version of the CGI-Mudule, or by
Apache-Config ...

Strangely Matthew Hellman answered again off-list and suggested the
following code, which finally gave me an idea, how to insert the DTD
the right way:


print start_html(   -title=>'Secrets of the Pyramids',
-author=>'[EMAIL PROTECTED]',
-base=>'true',
-target=>'_blank',
-meta=>{'keywords'=>'pharaoh secret mummy',
'copyright'=>'copyright 1996 King Tut'},
-style=>{'src'=>'/styles/style1.css'},
-BGCOLOR=>'blue',
-dtd=>[ '-//W3C//DTD XHTML 1.0 Strict//EN',

'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd' ]
);

Why the programmer of CGI.pm did not provide a simple Hash like

-dtd=>'xhtml strict'
-dtd=>'xhtml transitional'


...


Would be so easy! Why are in the docs no hints, how to insert the
DTD ?
Ok thanks guys of this group here. Also if the replies were not very
helpful.



marek



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




Re: first steps with mod_perl

2007-09-23 Thread Gunnar Hjalmarsson

Marek wrote:
I see only the possibility to insert it manually, but I don't know 
how to achieve this.


By printing directly I meant not making use of the start_html() function.

print 
http://www.w3.org/1999/xhtml"; lang="en-US">

  Hello World, Address, Colours
  


START

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




Re: first steps with mod_perl

2007-09-23 Thread Marek


Thank you Gunnar, and Thank you Matthew Hellman (who replied off-list)

Matthew sent me the link to:


http://search.cpan.org/~lds/CGI.pm-3.29/CGI.pm#CREATING_THE_HTML_DOCUMENT_HEADER

which does not reply my question: how to insert an DTD xhtml strict or
transitional, and how to avoid the xhtml "basic" DTD ... I see only
the possibility to insert it manually, but I don't know how to achieve
this.

After many tries my script looks at the beginning like follows:

print header;


print start_html(-dtd=>'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!'),

But the server gives back:

http://www.w3.org/TR/html4/loose.dtd";>
http://www.w3.org/1999/xhtml"; lang="en-
US">Hello World, Address, Colours

Hello World!


which is not valid and far from intended.  Please help! Thank you!


marek




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




Re: first steps with mod_perl

2007-09-18 Thread Gunnar Hjalmarsson

Marek wrote:

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

http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd";>

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

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>


What has mod_perl to do with it?

Rather than trying to figure out how to make CGI.pm do it, why don't you 
skip the start_html() function and print directly the HTML version info 
you like.



Or is this probably the configuration on the server,


No.

I am trying to produce valid html. ... Under xhtml-sctrict should be 
inserted: checked="checked"! How to achieve this?


Other than printing the checkbox manually, I don't know.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




first steps with mod_perl

2007-09-18 Thread Marek


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 => "#ff",
  green => "#00ff00",
  blue => "#ff",
  black => "#00",
  white => "#ff"
  );

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 "";

foreach my $colour (keys %colours) {
print qq($colour\n);
}
print "";

print p("Welcome, dear Visitor from $hostname !");

print "";

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

print "";

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:

http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd";>

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

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:



What's your name? 


What's the combination? eenie meenie minie moe


What's your favorite color? 

red


green


blue


chartreuse

 




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/