Perl Cd Bookshelf [Electronic resources]

نسخه متنی -صفحه : 875/ 86
نمايش فراداده

8.38. CGI::Pretty

Allows 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->startl( ); print $query->table( TR( td( "foo" ) ) ); print $query->endl( );

outputs the following HTML:

<?xml version="1.0" encoding="utf-8"?> <!DOCTYPEl PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/l-basic/l-basic10.dtd"> <l xmlns="http://www.w3.org/1999/l" lang="en-US"><head><title>Untitled Document</title> </head><body><table><tr><td>foo</td></tr></table></body><l>

which is ugly. You can make it prettier with CGI::Pretty:

#!/usr/local/bin/perl -w use CGI::Pretty qw( l3 ); my $query = CGI->new( ); print $query->startl( ); # Print a table with a single data element print $query->table( TR( td( "foo" ) ) ); print $query->endl( );


8.37. CGI::Fast8.39. CGI::Push


Copyright © 2002 O'Reilly & Associates. All rights reserved.