Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > why cgi print out everything to the page?

Reply
Thread Tools

why cgi print out everything to the page?

 
 
robertchen117@gmail.com
Guest
Posts: n/a
 
      02-13-2007
The code is below,
Why on the page, it will also print out the name according to these
two lines :
$name = param('name'),
$name =~ s/\^/\\^/,



# CGI script that creates a fill-out form
# and echoes back its values.

use CGI qw/:standard/;
print header,
start_html('A Simple Example'),
h1('A Simple Example'),
start_form,
"What's your name? ",textfield('name'),p,
"What's the combination?", p,
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']),p,
submit,
end_form,
hr;

if (param()) {
$name = param('name'),
$name =~ s/\^/\\^/,
print "Your name is",em(param('name')),p,
"The keywords are: ",em(join(", ",param('words'))),p,
"Your favorite color is ",em(param('color')),
hr;
}

 
Reply With Quote
 
 
 
 
Mumia W.
Guest
Posts: n/a
 
      02-13-2007
On 02/13/2007 12:47 AM, wrote:
> The code is below,
> Why on the page, it will also print out the name according to these
> two lines :


I don't understand the question. Perhaps you meant to ask "How do I
print the name after having preformed these changes:"

> $name = param('name'),
> $name =~ s/\^/\\^/,
>
>
>
> # CGI script that creates a fill-out form
> # and echoes back its values.
>


Even though the example in CGI.pm doesn't use them, it's best to use
strictures and warnings.

use strict;
use warnings;


> use CGI qw/:standard/;
> print header,
> start_html('A Simple Example'),
> h1('A Simple Example'),
> start_form,
> "What's your name? ",textfield('name'),p,
> "What's the combination?", p,
> 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']),p,
> submit,
> end_form,
> hr;
>
> if (param()) {


my $name;

> $name = param('name'),
> $name =~ s/\^/\\^/,


Why are you putting commas rather than semicolons after these two lines?


> print "Your name is",em(param('name')),p,
> "The keywords are: ",em(join(", ",param('words'))),p,
> "Your favorite color is ",em(param('color')),


p, "Transformed name: @{[ escapeHTML($name) ]}",

> hr;
> }
>



--
Windows Vista and your freedom in conflict:
http://www.regdeveloper.co.uk/2006/1...eula_analysis/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
EOFError why print(e) cannot print out any information ? iMath Python 2 12-26-2012 12:21 PM
Not Quite Everything for a Theory of Everything fitz VOIP 0 02-28-2010 04:42 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
PIX 501 - allow icmp out but deny everything else out nicough@gmail.com Cisco 2 11-18-2006 03:44 PM
XSL Transform - Why is it writing out everything? daz_oldham XML 4 05-24-2006 01:43 PM



Advertisments