Perl Statements

This brief section covers the main Perl statements and structures that you will use in a typical CGI page. Most of the statements work the same as they do in JavaScript, but the variables must be prefaced with the correct symbols, and some of the formats might be slightly different.

Output

As you have seen in examples in this chapter, the print statement seems to be the most common output statement. It is. Three key types of print statements will help you get started in Perl with CGI:

  • Print literal: print "Hamster \n\n";

  • Print variable: print $bigshot;

  • Print HTML: print "<strong> Tough </strong>";

A print statement that outputs HTML tags such as <b> is really a formatting technique in CGI, just as using the backslash with n ( ...

Get JavaScript Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.