8.38. CGI::PrettyAllows users of CGI to output nicely formatted HTML code by adding carriage returns and indentations to HTML markup for easy readability. For example, the following code: #!/usr/local/bin/perl -w use CGI qw(:all); my $query = CGI->new( ); print $query->start_html( ); print $query->table( TR( td( "foo" ) ) ); print $query->end_html( ); outputs the following HTML:
which is ugly. You can make it prettier with CGI::Pretty: #!/usr/local/bin/perl -w use CGI::Pretty qw( :html3 ); my $query = CGI->new( ); print $query->start_html( ); # Print a table with a single data element print $query->table( TR( td( "foo" ) ) ); print $query->end_html( );
Copyright © 2002 O'Reilly & Associates. All rights reserved. |
|