Wednesday, January 6, 2010

10.9 What We Didn't Talk About



[ Team LiB ]










10.9 What We Didn't Talk About


There is much more to Embperl that we didn't discuss. Here are a few topics that you might investigate as you proceed in your Open Source web development career.



10.9.1 Persistent Database Connections


In this project, each time one of the pages is requested, a new database connection is made. This can generate a lot of overhead, especially if the page receives a lot of hits. Embperl can use Apache::DBI to maintain persistent connections to the MySQL database. For more information, check out Apache::DBI at CPAN.



10.9.2 Session Handling with %udat and %mdat


Embperl allows you to easily track sessions with %udat, %mdat, and Apache::Session. The module Apache::Session must be installed for the session handling to work.


The hash %udat, if used within an HTML page, creates a session for the user and sends session information to the user via a cookie. This session is then remembered the next time the user visits the site, restoring %udat to the value from the last visit.


The hash %mdat, if used with an HTML page, stores persistent data for the page/module that was requested. This information is restored into %mdat the next time the page is requested, regardless of which user requests it.


For more information, see perldoc HTML::Embperl.



10.9.3 Tons of Variables


Many more Embperl variables are available. The following list is just a sample. For a complete list, check out the Embperl web page or perldoc.




@ffld
An array containing the fields in the form that was posted (usually in the same order as they appear in the form).




$maxrow, $maxcol
The maximum number of rows or columns to display in a table. These variables help prevent infinite loops when creating tables while using $row and $col (the default for $maxrow is 100 and for $maxcol is 10).




$cnt
The number of table cells currently displayed (used with $row and $col).




$tabmode
A value that affects how the end of table creation is determined when using $row and $col.




$escmode
A value that affects HTML- and URL-escaping.




LOG
The log file filehandle�print to this filehandle to add to the log file (/tmp/embperl.log by default).




OUT
Embperl's output stream�anything printed to it ends up being sent out by the server (the same as a [+ ... +] block).




%http_headers_out
A hash containing keys and values that are sent in the header. A redirect can be accomplished with [- $http_headers_out{Location} = "http://www.onsight.com/"; -].





10.9.4 XML and XSLT Support


Starting with version 2.0b4, Embperl integrates with XML and XSLT. See the Embperl web page or perldoc for details.






    [ Team LiB ]



    No comments: