Link to home
Start Free TrialLog in
Avatar of ocsurf
ocsurf

asked on

extra print commands

Im not sure how to work the question. But im learning CGI and i saw the command

print p("<b>Thank you for your order $name!</b>") ;

what does the methond p() do? And are there any other like this one? IE i saw qq() on one question and it said it is for double qoutes.

thanks
Avatar of prady_21
prady_21

i think it is an error unless the experts think otherwise

infact it would be helpful if you post the full code where you saw the  command
Avatar of ocsurf

ASKER

#!/usr/local/bin/perl -w


use CGI qw(:standard);

print header,

start_html("Ice Cream Stand"), h1("Ice Cream Stand");
if (param()) { # the form has already been filled out
    my $who = param("name");
    my $flavor = param("flavor");
    my $scoops = param("scoops");
    my $taxrate = 1.0743;
    my $cost = sprintf("%.2f", $taxrate * (1.00 + $scoops * 0.25));
    print p("Ok, $who, have $scoops scoops of $flavor for \$$cost.");
} else { # first time through, so present clean form
    print hr(); # draw a horizontal rule before the form
    print start_form();
    print p("What's your name? ", textfield("name"));
    print p("What flavor: ", popup_menu("flavor", ['mint','cherry','mocha']));
    print p("How many scoops? ", popup_menu("scoops", [ 1..3 ]));
    print p(submit("order"), reset("clear"));
    print end_form(), hr();
}
print end_html;
If you're using the CGI module, the 'p' function just puts the text in a <p> tag pair.
ASKER CERTIFIED SOLUTION
Avatar of fantasy1001
fantasy1001

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
An interesting thing about most of the html shortcut functions supplied by CGI.pm — p( ), b( ), h1( ), h2( ), etc — is that they are are all generated from the same template using the autoloader.

Fantasy has answered both parts of your question. I suggest you accept his answer. Of course, we're ready to explain more if need be.
Avatar of ocsurf

ASKER

Thanks all for the help