Solved

extra print commands

Posted on 2003-10-28
6
154 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 5

Accepted Solution

by:
fantasy1001 earned 125 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now