Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

extra print commands

Posted on 2003-10-28
6
Medium Priority
?
209 Views
Last Modified: 2010-03-05
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
0
Comment
Question by:ocsurf
6 Comments
 
LVL 3

Expert Comment

by:prady_21
ID: 9638305
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
0
 
LVL 1

Author Comment

by:ocsurf
ID: 9638316
#!/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;
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9638438
If you're using the CGI module, the 'p' function just puts the text in a <p> tag pair.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 5

Accepted Solution

by:
fantasy1001 earned 500 total points
ID: 9639638
About print p,
this is the cgi.m shortcut key for adding the <p> pair. You can also print others tag like this for example: print br(..., print hr(...), print h2("this is font2")

About qq:
By default the print function, and most other Perl functions, use the " sign to deliminate. Using the qq command, we can pick a replacement for the " sign so we can use the " sign inside the print without needing to escape it.

Instead of writing:

  print "\"Hello\", Joe said.";
You could also write:

  print qq!"Hello", Joe said.!;

Thanks & Cheers

0
 
LVL 20

Expert Comment

by:jmcg
ID: 9639894
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.
0
 
LVL 1

Author Comment

by:ocsurf
ID: 9642203
Thanks all for the help
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question