PRETTY-PRINTING HTML
PRETTY-PRINTING HTML
By default, all the HTML produced by these functions
comes out as one long line without carriage returns or indentation. This is
yuck, but it does reduce the size of the documents by 10-20%. To get
pretty-printed output, please use CGI::Pretty, a subclass contributed by
Brian Paulsen.
Optional Utility Functions
In addition to the standard imported functions, there
are a few optional functions that you must request by name if you want them.
They were originally intended for internal use only, but are now made available
by popular request.
escape(), unescape()
use
CGI qw/escape unescape/;
$q
= escape('This $string contains ~wonderful~ characters');
$u
= unescape($q);
These functions escape and unescape strings according to
the URL hex escape rules. For example, the space character will be converted
into the string "%20".
escapeHTML(), unescapeHTML()
use
CGI qw/escapeHTML unescapeHTML/;
$q
= escapeHTML('This string is <illegal> html!');
$u
= unescapeHTML($q);
These functions escape and unescape strings according to
the HTML character entity rules. For example, the character < will be escaped
as <.
compile()
Ordinarily CGI.pm autoloads most of its functions on an
as-needed basis. This speeds up the loading time by deferring the compilation
phase. However, if you are using mod_perl, FastCGI or another system that uses a
persistent Perl interpreter, you will want to precompile the methods at
initialization time. To accomplish this, call the package function
compile() like this:
use
CGI ();
CGI->compile(':all');
The arguments to compile() are a list of method
names or sets, and are identical to those accepted by the use
operator.
|