why cgi print out everything to the page?

Discussion in 'Perl Misc' started by robertchen117@gmail.com, Feb 13, 2007.

  1. Guest

    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;
    }
    , Feb 13, 2007
    #1
    1. Advertising

  2. Mumia W. Guest

    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/10/29/microsoft_vista_eula_analysis/
    Mumia W., Feb 13, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. daz_oldham
    Replies:
    4
    Views:
    411
    daz_oldham
    May 24, 2006
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    838
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,661
    Smokey Grindel
    Dec 2, 2006
  4. Sunfire
    Replies:
    2
    Views:
    638
    Sunfire
    Nov 5, 2007
  5. iMath
    Replies:
    2
    Views:
    137
    Peter Otten
    Dec 26, 2012
Loading...

Share This Page