CGI::Pretty - module to produce nicely formatted HTML code
use CGI::Pretty qw( :html3 ); # Print a table with a single data element print table( TR( td( "foo" ) ) );
CGI::Pretty is a module that derives from CGI. It's sole function is to allow users of CGI to output nicely formatted HTML code.
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>
The <A> and <PRE> tags are not formatted. If these tags were formatted, the user would see the extra indentation on the web browser causing the page to look different than what would be expected. If you wish to add more tags to the list of tags that are not to be touched, push them onto the @AS_IS array:
@AS_IS
push @CGI::Pretty::AS_IS,qw(CODE XMP);
This section intentionally left blank.
Brian Paulsen <bpaulsen@lehman.com>, with minor modifications by Lincoln Stein <lstein@cshl.org> for incorporation into the CGI.pm distribution.
Copyright 1998, 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.
Bug reports and comments to bpaulsen@lehman.com. You can also write to lstein@cshl.org, but this code looks pretty hairy to me and I'm not sure I understand it!
CGI
To install CGI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI
CPAN shell
perl -MCPAN -e shell install CGI
For more information on module installation, please visit the detailed CPAN module installation guide.