7.6. CGI.pm HTML Shortcuts

In addition to the methods discussed previously, CGI.pm has functions for most of the commonly used HTML tags, including headings (h1(), h2(), h3(), etc.), paragraph breaks (p()), lists (li(), dl(), ul(), dd(), etc.), and text-formatting commands (i(), em(), blockquote()). See the CGI.pm documentation for details of all the shortcuts available.

7.6.1. Using HTML Shortcuts

Using these shortcuts is as straightforward as the previous example. Printing a heading:

<H1>Welcome to www.opensourcewebbook.com</H1> 

becomes:

$server_name = `/bin/hostname`; 
print h1("Welcome to $server_name") 

An HTML paragraph, <P>, is formatted as print p(); (no arguments), while

print p(´This is a new paragraph´); 

is equivalent to this: ...

Get Open Source Web Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP 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.