use CGI::Pretty qw( :html3 ); # Print a table with a single data element print table( TR( td( "foo" ) ) );
When using the CGI module, the following code:
print table( TR( td( ``foo'' ) ) );
produces the following output:
<TABLE><TR><TD>foo</TD></TR></TABLE>
If a user were to create a table consisting of many rows and many columns, the resultant HTML code would be quite difficult to read since it has no carriage returns or indentation.
CGI::Pretty fixes this problem. What it does is add a carriage return and indentation to the HTML code so that one can easily read it.
print table( TR( td( "foo" ) ) );
now produces the following output:
<TABLE>
<TR>
<TD>foo</TD>
</TR>
</TABLE>
With all those considerations, it is recommended that CGI::Pretty be used primarily for debugging.
push @CGI::Pretty::AS_IS,qw(XMP);
$CGI::Pretty::INDENT = "\t\t";
would cause the indents to be two tabs.
Similarly, if you wish to have more space between lines, you may change the $LINEBREAK variable:
$CGI::Pretty::LINEBREAK = "\n\n";
would create two carriage returns between lines.
If you decide you want to use the regular CGI indenting, you can easily do the following:
$CGI::Pretty::INDENT = $CGI::Pretty::LINEBREAK = "";
Copyright 1999, Brian Paulsen. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Address bug reports and comments to: https://github.com/leejo/CGI.pm/issues
The original bug tracker can be found at: https://rt.cpan.org/Public/Dist/Display.html?Queue=CGI.pm
When sending bug reports, please provide the version of CGI.pm, the version of Perl, the name and version of your Web server, and the name and version of the operating system you are using. If the problem is even remotely browser dependent, please provide information about the affected browsers as well.