Home
61.
How do you round off numbers in Perl?

To round off numbers without printing them, use sprintf. To print numbers with less precision, use printf.

62.
What are the values that Perl considers false?

Perl has three false values: 0, the empty string "", and the undefined value.

63.
Why are there different operators for number and string comparisons?

Perl has different operators for numbers and strings because of its capability to auto-convert scalar values and the differences in handling both those values.

64.
Define what a short-circuiting logical operator does.

Short-circuiting operators only evaluate their right-side operands when necessary. If the value of the left-side operator determines the overall value of the expression (for example, if the left side of a && operator is false), the expression will stop.

65.
How is a pattern-matching test different from an equality test?

Equality tests return true if the scalars on both sides of the operator are exactly equal. Pattern matching tests result true of the scalar on the left side of the operator contains characters that match the pattern on the right side of the operator.

66.
What does CGI stand for? What’s it used for?

CGI stands for Common Gateway Interface, and refers to programs that run on the Web server in response to requests from a Web browser (commonly from a form on an HTML page).

67.
What does the CGI.pm module give you? How do you get it and use it?

The CGI.pm module provides behavior for writing, running, and debugging CGI scripts. It provides a number of subroutines for managing input to and output from those scripts as well as other utility subroutines for just about any aspect of CGI you can think of.
The CGI.pm module is shipped with most current versions of Perl. If it is not already available as part of your Perl distribution, you can download and install it from the URL mentioned earlier in this lesson.
To use the CGI module, you import it like you do any other module: with use and an import tag such as :standard or :all.

68.
Why would you want to run a CGI script on the command line before trying to run it via a Web page?

Running a CGI script from the command line is usually easier to find the smaller syntax or basic errors you might have made without needing to install the script on the Web server, connect to the Internet, and so on. By running the script on the command line and giving it sample data, you can test your script before actually putting it online.

69.
Why would you want to run a CGI script on the command line before trying to run it via a Web page?

The param() subroutine is used to find out the values of any form elements on the Web page that called this script. Without any arguments, param() returns a list of keys referring to the names of the form elements. With a key argument (a string), param() returns the value associated with that form element.

70.
List three ways to print HTML code as output for your CGI script.

You can print HTML code using one of these methods:
-> Use regular print statements. Watch out for embedded quotes!
-> Here document
-> Various subroutines via the CGI.pm module.