zhshqzyc has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: CGI script to create a HTML document
by davorg (Chancellor) on Nov 28, 2006 at 09:58 UTC

    If you're going to repost a question that you asked previously, then it's polite to include a link to the previous version so that people can look at the previous discussion and know what has already been tried. It would also be helpful if you explained why you chose to ignore much previous advice that you were given.

    In this particular case, I have already explained that there are problems in the way that you use the "param" function and have pointed you at the documentation. Why do you think we would continue to help you if you ignore the help that you are given?

    But. I'm in a good mood (so far) today. So here are explainations for the problems that you mention.

    • Name: You don't print the value of the name input. You only print the string "name".
      $q->p( "Your name is ", $q->strong("name")),
    • Age: You don't print the value of the age input. You only print a new text input field.
      $q->p({-style=>"text-decortation:underline"}, "Your age is ",$q->textfield(-name=>"age")),
    • Blue: Your style attribute for the colour is wrong.
      $q->span({-style=>color=>"blue"},$pay_text)),

    Please read the documentation for CGI.pm again. It really doesn't look like you have understood it.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: CGI script to create a HTML document
by Tanktalus (Canon) on Nov 28, 2006 at 04:11 UTC

    You're missing one pragma: warnings.

    use warnings;
    Then you'll notice (maybe - if you scroll back):
    Odd number of elements in anonymous hash at ./x.pl line 27.
    That {-style=>color=>"blue"} looks awfully suspicious. Perhaps you meant {-style => 'color: blue'} instead?

Re: CGI script to create a HTML document
by friedo (Prior) on Nov 28, 2006 at 04:48 UTC
Re: CGI script to create a HTML document
by ikegami (Patriarch) on Nov 28, 2006 at 04:10 UTC
    • my $pay = $q->param(payment=>"discover","master","check");
      should be
      my $pay = $q->param('payment');

    • -style=>"text-decortation:underline"
      should be
      -style=>"text-decoration:underline"

    • -style=>color=>"blue"
      should be
      -style=>"color:blue"

    If something should be underlined/blue/whatever and it isn't, check the syntax of the code that should cause those changes to happen, both in the source and in the generated HTML.

Re: CGI script to create a HTML document
by Melly (Chaplain) on Nov 28, 2006 at 10:47 UTC

    Please read the answers to your previous post of this problem.

    Several of us took the time to offer significant help, and I'm starting to wonder why we bothered...

    Tom Melly, tom@tomandlu.co.uk
      I really appreciate everybody's warmly help. I am a new comer to perl. I don't fully understand the previous post's answer, so I really want to get help. Here still have some compilation errors.(near $q->end_html) Please assist me again. Thank you very much!
      #!C:/Perl/bin/perl use strict; use CGI::Pretty qw( -debug ); use CGI::Carp qw( fatalsToBrowser ); my $q = new CGI; my $pay = $q->param('payment'); my $pay_text; if ( $pay eq "discover" ) { $pay_text = "Discover Card"; } elsif ( $pay eq "master" ) { $pay_text = "Master Card"; } elsif ( $pay eq "check" ) { $pay_text = "by check"; } else { $pay_text = "unknown method"; } print $q->header, $q->start_html( -title=>"Welcome", -bgcolor=>"pink"), $q->p( "Your name is ", $q->b("name")), $q->p({-style=>"text-decoration:underline"},"Your age is ",$q->t +extfield(-name=>"age")), $q->p( "Your method of payment is ", $q->span({-style=>"color:blue"},$pay_text), $q->end_html;

        Close, but you are missing a closing bracket - change:

        $q->p( "Your method of payment is ", $q->span({-style=>"color:blue"},$pay_text),

        to (indented for clarity)

        $q->p("Your method of payment is ", $q->span({-style=>"color:blue"},$pay_text) ),
        map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e** 2-$d**2+$b);$c=$d**2+$e**2>4?_:0}1..99;print$c}0..59;print$/}0..20;
        Tom Melly, pm@tomandlu.co.uk