HTML::Embperl - Embed Perl in Your HTML Documents Copyright (c) 1997-2000 Gerald Richter / ECOS GmbH You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. ### !! IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !! ### ### ### This is the first BETA release of Embperl 2.0, before installing ### please read the README.v2. Documentation is not yet updated to ### reflect the changes in 2.0, everything that has changed is ### documented in README.v2. Since this is the first beta you ### shouldn't use it in a production evnironment! ### ### ### !! IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !! IMPORTANT !! Hints for using Embperl 2.x --------------------------- Embperl 2 has a totaly rewritten core. It contains nearly 7500 lines new (mostly C-) code. Also I have done a lot of testing, don't expect it to work without errors! Please report any weired behaviour to the embperl mailing list, but be sure to read this whole README to understand what can't work so far. The Embperl core now works in a totaly different way. It is divided into smaller steps: 1 reading the source 2 parseing 3 compiling 4 executing 5 outputing Further version will allow to replace every single step of this pipeline with custom modules. Also it will be possible to cascade multiple processors. This allows for example to have Embperl and SSI in one file and to parse the file only once, feeding it first to the SSI processor and afterwards to the Embperl processor. Also the parser will be exchangeable in future version to allow for example to use an XML parser and an XSLT stylesheet processor. These new execution scheme is also faster, because html tags and metacommands are parsed only once (Perl code was also (and is still) cached in 1.x) My first benchmarks show 50%-100% faster execution under mod_perl for pages longer then 20K (For short pages ( < 5K ouput) you won't see such a great difference) and without any external database access. Another new feature is that the syntax of the Embperl parser is defined within the module HTML::Embperl::Syntax and can be modified as nessecary. See the file Embperl/Syntax.pm how it looks like and perldoc HTML::Embperl::Syntax for a short description. A further verion will add an API to this syntax module, so custom syntaxes can be easily added, without modifiy Syntax.pm itself. Also new is the possibility to cache (parts of) the output. The following difference to Embperl 1.x apply: ------------------------------------------------------ - The following options can currently only set from the httpd.conf: optRawInput, optKeepSpaces - The following options are currently not supported: optDisableHtmlScan, optDisableTableScan, optDisableInputScan, optDisableMetaScan - Nesting must be properly. I.e. you cannot put a tag (for an dynamic table) inside an if and the
inside another if. (That still works for static tables) - optUndefToEmptyValue is always set and cannot be disabled. - [$ foreach $x (@x) $] requires now the bracket around the array (like Perl) - [+ +] blocks must now contain a valid Perl expression. Embperl 1.x allows you to put multiple statements into such a block. For performance reasons this is not possible anymore. Also the expression must _not_ terminated with a semikolon. To let old code work, just wrap it into a do e.g. [+ do { my $a = $b + 5 ; $a } +] The following things are not fully tested/working yet: ------------------------------------------------------ - [- exit -] - [- print OUT "foo" -] - safe namespaces Embperl 1.x compatibility flag ------------------------------ If you don't have a separate computer to make the test setup, you can include PerlSetEnv EMBPERL_EP1COMPAT 1 at the top level of your httpd.conf, then Embperl will behave just the same like Embperl 1.3b7. In the directories where you make your tests, you include a PerlSetEnv EMBPERL_EP1COMPAT 0 to enable the new engine. but _DON'T_ use this one a production machine. While this compatibility mode is tested and shows no problems for me, it's not so hard tested as 1.3b7 itself! Addtional Config directives --------------------------- execute parameter / httpd.conf environment variable / name inside page (must set inside [! !]) cache_key / EMBPERL_CACHE_KEY / $CACHE_KEY literal string that is appended to the cache key cache_key_options / EMBPERL_CACHE_KEY_OPTIONS / $CACHE_KEY_OPTIONS ckoptCarryOver = 1, use result from CacheKeyFunc of preivious step if any ckoptPathInfo = 2, include the PathInfo into CacheKey ckoptQueryInfo = 4, include the QueryInfo into CacheKey ckoptDontCachePost = 8, don't cache POST requests (not yet implemented) Default: all options set expired_func / EMBPERL_EXPIRES_FUNC / &EXPIRES function that should be called when build a cache key. The result is appended to the cache key. cache_key_func / EMBPERL_CACHE_KEY_FUNC / &CACHE_KEY function that is called everytime before data is taken from the cache. If this funtion returns true, the data from the cache isn't used anymore, but rebuild. Function could be either a coderef (when passed to Execute), a name of a subroutine or a string starting with "sub " in which case it is compiled as anoymous subroutine. expires_in / EMBPERL_EXPIRES_IN / $EXPIRES Time in seconds that the output schould be cached. (0 = never, -1 = forever) ------------------- Enjoy Gerald