.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Faq 3pm" .TH Faq 3pm "2023-01-22" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Embperl::Faq \- How to embed Perl code in your HTML docs .SH "CONTENTS" .IX Header "CONTENTS" .ie n .IP """Downloading, Compiling & Installing""" 4 .el .IP "``Downloading, Compiling & Installing''" 4 .IX Item "Downloading, Compiling & Installing" .PD 0 .ie n .IP """Common Problems""" 4 .el .IP "``Common Problems''" 4 .IX Item "Common Problems" .ie n .IP """Common Questions""" 4 .el .IP "``Common Questions''" 4 .IX Item "Common Questions" .ie n .IP """Escaping & Unescaping""" 4 .el .IP "``Escaping & Unescaping''" 4 .IX Item "Escaping & Unescaping" .ie n .IP """Debugging""" 4 .el .IP "``Debugging''" 4 .IX Item "Debugging" .ie n .IP """Customizing""" 4 .el .IP "``Customizing''" 4 .IX Item "Customizing" .ie n .IP """Optimizing & Fine Tuning""" 4 .el .IP "``Optimizing & Fine Tuning''" 4 .IX Item "Optimizing & Fine Tuning" .ie n .IP """Additional Help""" 4 .el .IP "``Additional Help''" 4 .IX Item "Additional Help" .PD .SH "Downloading, Compiling & Installing" .IX Header "Downloading, Compiling & Installing" For basics on downloading, compiling, and installing, please see the \&\*(L"\s-1INSTALLATION\*(R"\s0 in \s-1INSTALL\s0 in the Embperl documentation. Please be sure to load Embperl at server startup \- if you do not, various problems may result. An exception to that rule is when you have compiled mod_perl with \&\fB\s-1USE_DSO\s0\fR. In this case you \fBmust not\fR load Embperl at server statup, neither via an use in your startup.pl file, nor via PerlModule from your httpd.conf. .SS "Is there a binary distribution of Embperl for Unix?" .IX Subsection "Is there a binary distribution of Embperl for Unix?" No. .SS "Is there a binary distribution of Embperl for Win32?" .IX Subsection "Is there a binary distribution of Embperl for Win32?" Win \s-1NT/95/98\s0 binarys for Apache/perl/mod_perl/Embperl are available from ftp://theoryx5.uwinnipeg.ca/pub/other/ . A european mirror is at http://www.robert.cz/misc/ . .SS "I want to run Embperl with mod_perl under Apache. In what order should I do the compiling?" .IX Subsection "I want to run Embperl with mod_perl under Apache. In what order should I do the compiling?" First mod_perl and Apache, then Embperl. .SS "I'm getting:" .IX Subsection "I'm getting:" \&../apache_1.3.0/src/include/conf.h:916: regex.h: No such file or directory .PP Try compiling Embperl again, like this: .PP .Vb 1 \& make DEFS=\-DUSE_HSREGEX .Ve .SS "I'm trying to build HTML::Embperl, and while running 'make' i get:" .IX Subsection "I'm trying to build HTML::Embperl, and while running 'make' i get:" cc: Internal compiler error: program cc1 got fatal signal 11 make: *** [epmain.o] Error 1 .PP \&\s-1GCC\s0 croaking with signal 11 frequently indicates hardware problems. See http://www.bitwizard.nl/sig11/ .SS "I have a lot of errors in 'make test' from mod_perl when using Embperl" .IX Subsection "I have a lot of errors in 'make test' from mod_perl when using Embperl" Try recompiling Perl and all modules \*(-- this can sometimes make those annoying error messages disappear! .SS "How can I prevent 'make test' from running some of the tests?" .IX Subsection "How can I prevent 'make test' from running some of the tests?" For example, I don't allow \s-1CGI\s0 scripts, so 'make test' fails at \s-1CGI.\s0 How do I run just the other tests? .PP Try: .PP .Vb 3 \& $ make test TESTARGS="\-\-help" \& # and for just offline and mod_perl: \& $ make test TESTARGS="\-hoe" .Ve .SS "Running 'make test' fails with an error message at loading of Embperl (even though mod_perl compiled and tested cleanly!)" .IX Subsection "Running 'make test' fails with an error message at loading of Embperl (even though mod_perl compiled and tested cleanly!)" see \*(L"I get symbol ap_* undefined/cannot resolve ap_*\*(R" .SS "I get symbol ap_* undefined/cannot resolve ap_*" .IX Subsection "I get symbol ap_* undefined/cannot resolve ap_*" This can happen when symbols in the Apache binary can not be found or are not being resolved correctly. .PP Some \s-1OS\s0 do this (for instance bsdos), and it can also happen if your Apache binary is set to strip symbol information out from binaries. .PP Try: .IP "1.) make clean" 4 .IX Item "1.) make clean" .PD 0 .IP "2.) perl Makefile.PL" 4 .IX Item "2.) perl Makefile.PL" .PD \&\s-1NOTE:\s0 answer _no_ to mod_perl support. (This is important!) .IP "3.) make test" 4 .IX Item "3.) make test" .PP If that works, it means that your installation of Embperl is \s-1OK,\s0 but is having problems resolving symbols with Apache. .PP Try rebuilding Apache and mod_perl from scratch, and make sure you do not strip symbols out of either. .PP On some systems/linker you need to tell the linker explicitly to export such symbols. For example FreeBSD linker needs the \&\f(CW\*(C`\-export\-dynamic\*(C'\fR option. .PP If you don't succeed with this approach, try statically linking Embperl to Apache/mod_perl (please see the next question for step-by-step instructions on how to do this). .SS "How can I build a statically-linked copy of Embperl with mod_perl support?" .IX Subsection "How can I build a statically-linked copy of Embperl with mod_perl support?" .IP "1.) go to your mod_perl directory, change to src/modules/perl and edit the Makefile so that it contains the line" 4 .IX Item "1.) go to your mod_perl directory, change to src/modules/perl and edit the Makefile so that it contains the line" .Vb 1 \& #STATIC_EXTS = Apache Apache::Constants HTML::Embperl .Ve .IP "2.) add a definition for \s-1EPDIR\s0 and change the ONJ= line so that it looks like this:" 4 .IX Item "2.) add a definition for EPDIR and change the ONJ= line so that it looks like this:" EPDIR=/usr/msrc/embperl OBJS=$(\s-1PERLSRC:\s0.c=.o) $(\s-1EPDIR\s0)/Embperl.o $(\s-1EPDIR\s0)/epmain.o $(\s-1EPDIR\s0)/epio.o (\s-1EP DIR\s0)/epeval.o $(\s-1EPDIR\s0)/epcmd.o $(\s-1EPDIR\s0)/epchar.o $(\s-1EPDIR\s0)/eputil.o .IP "3.) go to the mod_perl directory and run" 4 .IX Item "3.) go to the mod_perl directory and run" .Vb 1 \& perl Makefile.PL .Ve .IP "4.) go to the Embperl directory and do" 4 .IX Item "4.) go to the Embperl directory and do" .Vb 3 \& make clean \& perl Makefule.PL \& make .Ve .Sp (to compile in mod_perl support) .IP "5.) go back to the mod_perl directory and remake Apache by typing" 4 .IX Item "5.) go back to the mod_perl directory and remake Apache by typing" .Vb 1 \& make .Ve .Sp Now you have successfully built a httpd with statically-linked Embperl. .Sp \&\s-1NOTE:\s0 If you want to stop here, you can skip to step 11. and run a 'make install' in the Embperl directory to finish. .Sp But if you want to run Embperl tests and/or if you want to be able to use Embperl in offline or \*(L"vanilla\*(R" \s-1CGI\s0 mode, we need to continue: .IP "6.) go back to the Embperl directory" 4 .IX Item "6.) go back to the Embperl directory" .PD 0 .IP "7.) backup the file test/conf/config.pl" 4 .IX Item "7.) backup the file test/conf/config.pl" .IP "8.) now build Embperl again but _without_ mod_perl support" 4 .IX Item "8.) now build Embperl again but _without_ mod_perl support" .PD .Vb 3 \& make clean \& perl Makefile.PL \& make .Ve .IP "9.) restore your saved config.pl to test/conf/config.pl" 4 .IX Item "9.) restore your saved config.pl to test/conf/config.pl" (without this step, only the offline mode would be tested) .IP "10.) run 'make test' for Embperl" 4 .IX Item "10.) run 'make test' for Embperl" .PD 0 .IP "11.) do 'make install' for Embperl" 4 .IX Item "11.) do 'make install' for Embperl" .PD .PP \&\s-1NOTE:\s0 You should do it in this order, or it may not work. .PP \&\s-1NOTE:\s0 It seems to be necessary to load Embperl at server startup, either by PerlModule or in a PerlScript. See next question on how to do this. .SS "How do I load Embperl at server startup?" .IX Subsection "How do I load Embperl at server startup?" You can load Embperl at server startup by PerlModule or in a startup.pl: .IP "1.) edit your srm.conf file to read:" 4 .IX Item "1.) edit your srm.conf file to read:" .Vb 1 \& PerlModule HTML::Embperl .Ve .IP "2.) edit your startup.pl file to read:" 4 .IX Item "2.) edit your startup.pl file to read:" .Vb 1 \& use HTML::Embperl .Ve .PP \&\s-1NOTE 1:\s0 Either of these approaches can often 'fix' SIGSEVs in any mod_perl handler, not just Embperl. .PP \&\s-1NOTE 2:\s0 When mod_perl is compiled as loadable module (i.e. with \s-1USE_DSO\s0) you \fBmust not\fR load Embperl at server startup time! .SS "make test fails with a SIGxxxx, how can I obtain a stack backtrace from gdb?" .IX Subsection "make test fails with a SIGxxxx, how can I obtain a stack backtrace from gdb?" The eaiest way is .PP .Vb 4 \& make install \-> if Embperl is installed, it\*(Aqs easier \& gdb perl \-> start the debugger with perl binary \& set args test.pl \-> set the arguments for perl \& r \-> start the program \& \& \-> Here you should receive the signal \& \& share \-> makes sure all symbols are really loaded \& bt \-> show the backtrace .Ve .PP To get some more information it would be a good idea to compile Embperl with debugging information enabled. Therefore do .SS "How do I build Embperl with debugging information" .IX Subsection "How do I build Embperl with debugging information" .IP "edit the Makefile" 4 .IX Item "edit the Makefile" .PD 0 .IP "search for the line starting with '\s-1CC\s0 = ' add the \-g switch to the end of the line" 4 .IX Item "search for the line starting with 'CC = ' add the -g switch to the end of the line" .IP "search for the line starting with '\s-1LDDFLAGS\s0 = ' add the \-g switch to the end of the line" 4 .IX Item "search for the line starting with 'LDDFLAGS = ' add the -g switch to the end of the line" .IP "type make to build Embperl with debugging infomation" 4 .IX Item "type make to build Embperl with debugging infomation" .PD .PP now start the gdb as described before. .SS "make test fails with \s-1SIGXFSZ\s0" .IX Subsection "make test fails with SIGXFSZ" This may occur when the filesize limit for the account, either test is running as or the test httpd, is too small. Embperl make test generates a really large logfile! Yu must increase the filesize limit for that accounts. .SS "Embperl on \s-1SCO\s0 Unix" .IX Subsection "Embperl on SCO Unix" >From Red Plait .PP My \s-1OS\s0 is \s-1SCO\s0 Unix 3.2v4.2, Apache 1.3.4, perl 5.004_4, mod_perl 1.18 and Embperl\-1.1.1 .PP I done following: .IP "1)" 4 .IX Item "1)" I made HTML\-Embperl\-1.1.1 with no mod_perl support ( when I builded it with mod_perl 1.18 I can`t link it because it don`t finds ap_XXX functions. When I manually insert src/main/libmain.a from Apache 1.3.4 I got message \&\*(L"Symbol main is multiple defined in /src/main/libmain.a. and perlmain.o\*(R" ). Then I \*(L"make test\*(R" \- all tests was O`k. After this I \*(L"make clean\*(R", \*(L"perl Makefile.pl\*(R" with mod_perl support and \*(L"make install\*(R" .IP "2)" 4 .IX Item "2)" I installed mod_perl and \*(L"perl Makefile.PL\*(R", then \*(L"make\*(R" .IP "3)" 4 .IX Item "3)" because I have`nt dynamical loading ( very old and buggy \s-1OS\s0 ) I had to manually change src/modules/perl/perlxsi.c to insert bootstraps function`s and it`s invocations and also /src/Makefile to manually insert libXXX.a libraries .IP "In access.conf I insert code:" 4 .IX Item "In access.conf I insert code:" .Vb 5 \& PerlModule HTML::Embperl \& \& SetHandler perl\-script \& PerlHandler HTML::Embperl::handler \& .Ve .SS "Embperl and mod_perl on \s-1AIX\s0" .IX Subsection "Embperl and mod_perl on AIX" You need at least mod_perl 1.22. For mod_perl 1.22 and higher Embperl should compile out of the box on \s-1AIX.\s0 If you run into problems with undefined symbols (like \f(CW\*(C`ap_*\*(C'\fR) make sure you have the newest mod_perl version (as of this writing this is mod_perl 1.24_01). .SS "Embperl does not write to the logfile, because of missing permissions of the user Apache runs as." .IX Subsection "Embperl does not write to the logfile, because of missing permissions of the user Apache runs as." The apache server is started as root, then set the effective uid to user \*(L"www\*(R", who can then write to the embperl logfile (owned by root) file handle that is passed along. However, if this log file handle is later accidentally closed, then reopen, the www user would have problem writing to it? .PP The reopen is only done when the logfile name changes. As log as you don't change the name on the logfile, the logfile will stay open. .PP The problem (in this case) is, that Embperl init function ,(Init in epmain.c) calls OpenLog will an second argument of zero. Which will only save the filename. The log will actually opened on the first write to it (or at the start of the first request). At this time your Apache has already switch to user www. This is done to allow one to change the logfile name before a request, but after the init is already called (which is done when you or Apache \*(L"use\*(R" the module) .PP The current solutions is to write something to the log, before Apache changes it's user (i.e. in the startup.pl) .SS "Is it possible to install EmbPerl into a private directory on my Unix/Linux Internet Service Provider account of which I have no root privilege?" .IX Subsection "Is it possible to install EmbPerl into a private directory on my Unix/Linux Internet Service Provider account of which I have no root privilege?" Like any other Perl module it can. Read \*(L"perldoc ExtUtils::MakeMaker\*(R", to see which parameters are needed for Makefile.PL to change the installation directory. Additionally, you have to change the \f(CW@INC\fR path to contain your private directory and possibly paths to other object files. .PP Here are the brief details: .PP \&\fBRequirements\fR: .IP "\(bu" 4 At least Perl 5.004_04 .IP "\(bu" 4 cc or gcc (your isp must give you access to the gcc compiler) .IP "\(bu" 4 \&\s-1URI\s0 .IP "\(bu" 4 MIME::Base64 .IP "\(bu" 4 HTML::Parser .IP "\(bu" 4 HTML::HeadParser .IP "\(bu" 4 Digest::MD5 .IP "\(bu" 4 libnet .IP "\(bu" 4 libwww .IP "\(bu" 4 File::Spec (I believe you may have to install this too if you are using Perl 5.004_04 as it may not be a standard module) .PP \&\fBDirection\fR: .IP "\(bu" 4 Get your copy of EmbPerl (HTML\-Embperl\-x.x.tar.gz) .IP "\(bu" 4 % tar \-xvzf HTML\-Embperl\-x.x.tar.gz .IP "\(bu" 4 % cd HTML\-Embperl\-x.x .IP "\(bu" 4 % perl Makefile.PL PREFIX=/to/your/private/dir .IP "\(bu" 4 % make .IP "\(bu" 4 % make test .IP "\(bu" 4 % make install .PP Replace /to/your/private/dir with the path to the directory you want the module to be placed in. Now preface your \s-1CGI\s0 scripts with something like this: .PP [Alternative 1] .PP .Vb 2 \& #!/usr/bin/perl \-wT \& use CGI::Carp qw( fatalsToBrowser ); #recommend using this to report errors on die or warn to browser \& \& use lib \*(Aq/to/your/private/dir/lib\*(Aq; #for FILE::Spec \& use lib \*(Aq/to/your/private/dir/\*(Aq; #to find Embperl \& use lib \*(Aq/to/your/private/dir/i386\-linux/auto/HTML/Embperl\*(Aq; #to find Embperl compiled stuff \& \& #if for some very weird reason the above \*(Aquse lib\*(Aq pragma directive doesn\*(Aqt work, see Alternative 2 \& \& use HTML::Embperl; \& \& #your code below ... .Ve .PP [Alternative 2] .PP .Vb 2 \& #!/usr/bin/perl \-wT \& use CGI::Carp qw( fatalsToBrowser ); #recommend using this to report errors on die or warn to browser \& \& BEGIN { \& unshift @INC, \*(Aq/to/your/private/dir/lib\*(Aq; #for FILE::Spec \& unshift @INC, \*(Aq/to/your/private/dir/\*(Aq; #to find Embperl \& unshift @INC, \*(Aq/to/your/private/dir/i386\-linux/auto/HTML/Embperl\*(Aq; #to find Embperl compiled stuff \& } \& \& use HTML::Embperl; \& \& #your code below ... .Ve .PP When you make test, you may encounter superfluous warnings, you may want to change the test.pl that ships with EmbPerl from .PP .Vb 3 \& BEGIN \& { \& $fatal = 1 ; .Ve .PP to .PP .Vb 5 \& BEGIN \& { \& unshift @INC, \*(Aq/to/your/private/dir/lib\*(Aq; \& $fatal = 1 ; \& ... .Ve .PP because the test.pl may not be able to find FILE::Spec if you have it installed on a private directory for Perl 5.004_04. .PP Do something similar to the important file embpcgi.pl as you do for all your \s-1CGI\s0 scripts, like modifying the \f(CW@INC\fR as shown above, to allow perl to find in particular the EmbPerl shared obj files... .PP And when you invoke your \s-1CGI\s0 scripts like so, .PP http://www.yourdomain.com/cgi\-bin/embpcgi.pl/templateFiles/myNifty.epl .PP the script should work. .SH "Common Problems" .IX Header "Common Problems" The most common problems of all involve Escaping and Unescaping. They are so common, that an entire section on \&\*(L"Escaping & Unescaping\*(R" is devoted to them. .SS "When I use a module inside an Embperl page, it behaves weird when the source changes." .IX Subsection "When I use a module inside an Embperl page, it behaves weird when the source changes." Nothing weird here. Everything is well defined. Just let us try to understand how \fIPerl\fR, \fImod_perl\fR and \fIEmbperl\fR works together: .PP .Vb 1 \& "perldoc \-f use" tells us: \& \& Imports some semantics into the current package from the named module, \& generally by aliasing certain subroutine or variable names into your \& package. It is exactly equivalent to \& \& BEGIN { require Module; import Module LIST; } \& \& except that Module must be a bareword. .Ve .PP So what's important here for us is, that \f(CW\*(C`use\*(C'\fR executes a \f(CW\*(C`require\*(C'\fR and this is always done before any other code is executed. .PP .Vb 1 \& "perldoc \-f require" says (among other things): \& \& ..., demands that a library file be included if it hasn\*(Aqt already \& been included. .Ve .PP and .PP .Vb 2 \& Note that the file will not be included twice under the same specified \& name. .Ve .PP So now we know (or should know) that \fImod_perl\fR starts the Perl interpreter once when \fIApache\fR is started and the Perl interpreter is only terminated when Apache is terminated. Out of these two things follows, that a module that is loaded via \f(CW\*(C`use\*(C'\fR or \f(CW\*(C`require\*(C'\fR is only loaded once and will never be reloaded, regardless if the source changes or not. .PP So far this is just standard Perl. Things get a little bit more difficult when running under mod_perl (only Unix), because Apache forks a set of child processes as necessary and from the moment they are forked, they run on their own and don't know of each other. So if a module is loaded at server startup time (before the fork), it is loaded in all children (this can be used to save memory, because the code will actually only reside once in memory), but when the modul is loaded inside the child and the source changes, it could be happen, that one child has loaded an ealier version and another child has loaded a later version of that module, depending on the time the module is actualy loaded by the child. .PP That explains, why sometimes it works and sometimes it doesn't, simply because different children has loaded different versions of the same module and when you reload your page you hit different children of Apache! .PP Now there is one point that is special to Embperl to add. Since Embperl compiles every page in a different namespace, a module that doesn't contains a \f(CW\*(C`package foo\*(C'\fR statement is compiled in the namespace of the page where it is first loaded. Because Perl will not load the module a second time, every other page will not see subs and vars that are defined in the loaded module. This could be simply avoided by giving every module that should be loaded via \f(CW\*(C`use\*(C'\fR/\f(CW\*(C`require\*(C'\fR an explicit namespace via the package statement. .PP So what can we do? .IP "\(bu" 4 If a module change, simply restart Apache. That's works always. .IP "\(bu" 4 Use \fIApache::StatInc.\fR This will do a stat on every loaded module and compare the modification time. If the source has changed the module is reloaded. This works most times (but not all modules can be cleanly reloaded) and as the number of loaded modules increase, your sever will slow down, because of the stat it has to do for every module. .IP "\(bu" 4 Use \f(CW\*(C`do\*(C'\fR instead of \f(CW\*(C`require\*(C'\fR. \f(CW\*(C`do\*(C'\fR will execute your file every time it is used. This also adds overhead, but this may be accpetable for small files or in a debugging environment. (\fB\s-1NOTE:\s0\fR Be sure to check \f(CW$@\fR after a \f(CW\*(C`do\*(C'\fR, because do works like \f(CW\*(C`eval\*(C'\fR) .SS "Why doesn't the following line work?" .IX Subsection "Why doesn't the following line work?" .Vb 1 \& [+ $var . "". $foo . "". $bar +] .Ve .PP See what we mean? This is an Escaping & Unescaping problem for sure. You need to escape as ' <b> ' and you probably also need to read the section on \*(L"Escaping & Unescaping\*(R"... .ie n .SS "I'm getting: ""Glob not terminated at ...""" .el .SS "I'm getting: ``Glob not terminated at ...''" .IX Subsection "I'm getting: Glob not terminated at ..." This might be a problem with \*(L"Escaping & Unescaping\*(R" as well. .SS "My \s-1HTML\s0 is getting stripped out." .IX Subsection "My HTML is getting stripped out." Sounds like a problem with Escaping & Unescaping again! .PP Unless, of course, you have already read the section on Escaping & Unescaping, and it is still happening... Like if you are using optRawInput and your \s-1HTML\s0 is _still_ being stripped out... .SS "I _am_ using optRawInput, and my \s-1HTML\s0 _is_ still being stripped out!" .IX Subsection "I _am_ using optRawInput, and my HTML _is_ still being stripped out!" Aha! Well that's different! Never mind.. .PP It can be easy to accidentally set optRawInput too late in your code... .PP Try setting it in an extra Perl block ( [\- $optRawInput = 1 \-] ) earlier in the code, or in the server config, and see if that doesn't solve the problem... (optRawInput must be set before the block that uses it begins, as the block which uses it shouldn't be translated). .SS "Help! I got a \s-1SIGSEGV\s0! Ack!" .IX Subsection "Help! I got a SIGSEGV! Ack!" If Embperl is not compiled at server startup, it can cause error messages, SEGfaults, core dumps, buffer overflow, etc \- especially if you are using another module inside an Embperl page. As far as anyone can tell, this seems to be a Perl/mod_perl problem \- but maybe not. If you have any ideas, let me know. .PP To see the steps for loading Embperl at server startup, please see the section \*(L"Downloading, Compiling & Installing\*(R". .PP \&\s-1NOTE:\s0 When mod_perl is compiled with \fB\s-1USE_DSO\s0\fR it behaves vice versa and you may get SIGSEGVs when Embper is loaded at server startup time. .SS "I am having troubles with using Embperl in combination with Apache::Include inside a Apache::Registry script." .IX Subsection "I am having troubles with using Embperl in combination with Apache::Include inside a Apache::Registry script." This is a known problem, but it is a problem with mod_perl rather than with Embperl. It looks like mod_perl clears the request_rec after the first subrequest, so that it later doesn't know which subrequest was intended (unless it's explicitly specified). Try using: .PP .Vb 1 \& Apache::Include\->virtual("test.epl", $r); .Ve .PP (instead of just Apache::Include\->virtual(\*(L"test.epl\*(R"); where \f(CW$r\fR is the apache request rec) .SS "I can't get PerlSendHeader to work under Embperl?" .IX Subsection "I can't get PerlSendHeader to work under Embperl?" You don't need PerlSendHeader when using Embperl \- Embperl always sends its own httpd header. .SS "But how do I customize the header that Embperl is sending?" .IX Subsection "But how do I customize the header that Embperl is sending?" You'll find the answer to this and many other header issues in the \*(L"Common Questions\*(R" section. .SS "I can't figure out how to split a 'while' statement across two [\- \-] segments" .IX Subsection "I can't figure out how to split a 'while' statement across two [- -] segments" That isn't surprising, as you cannot split Perl statements across multiple [\- \-] blocks in Embperl :) You need to use a metacommand for that. The [$while$] metacommand comes to mind... :) .PP For a list of all possible metacommands, see the section on Meta-Commands in the Embperl documentation. .PP .Vb 3 \& [$ while $st \-> fetch $] \& #some html or other Embperl blocks goes here \& [$ endwhile $] .Ve .PP Newer Embperl versions (1.2b3 and above) supports the [* *] which can be used for such purposes. .PP .Vb 3 \& [* while ($st \-> fetch) { *] \& #some html or other Embperl blocks goes here \& [* } *] .Ve .PP While the later can use all Perl control structures, the first seems to me more readable and is better debugable, because Embperl controls the execution of the control structure it can do a quite better job in debug logging. .SS "My \s-1HTML\s0 tags like '<' '>' and '""' are being translated to <, > !!!" .IX Subsection "My HTML tags like '<' '>' and '""' are being translated to <, > !!!" Hey! Not you again!? I thought we already sent you to the \&\*(L"Escaping & Unescaping\*(R" section of the \s-1FAQ\s0?!?! ;) .SS "Netscape asks to reload the document" .IX Subsection "Netscape asks to reload the document" If you have something like this in your source, it may be the problem: .PP .Vb 1 \& .Ve .PP Netscape seems to have a problem in such cases, because the http header is only content-type text/html, while the \s-1META\s0 HTTP-EQUIV has an additional charset specified. If you turn optEarlyHttpHeader off, Embperl will automatically set the http header to be the same as the \s-1META\s0 HTTP-EQUIV. .ie n .SS "I get ""Stack underflow""" .el .SS "I get ``Stack underflow''" .IX Subsection "I get Stack underflow" The problem often occurs, when you have a tag in one file and a
tag in another file and you both include them in a main page (e.g. as header and footer). There are two workarounds for this problem: .IP "1. Set optDisableTableScan" 4 .IX Item "1. Set optDisableTableScan" This will avoid that Embperl takes any action on tables. You can disable/enable this (also multiple times) inside the page with .Sp .Vb 1 \& [\- $optDisableTableScan = 1 \-] .Ve .Sp If you put this at the top of your header/footer which you include with Execute, then the main page will still process dynamic tables. .IP "2. Add a as comment" 4 .IX Item "2. Add a
as comment" Add the following to the top of the footer document: .Sp .Vb 1 \&
\-\-> .Ve .Sp This will work also, because Embperl (1.x) will not scan for html comments .SH "Common Questions" .IX Header "Common Questions" The most common questions of all deal with \*(L"Escaping & Unescaping\*(R" \- they are so common that the whole next section is devoted to them. Less common questions are addressed here: .SS "How can I get my \s-1HTML\s0 files to be converted into Perl code which, as a whole, could then be compiled as function so that I could, for instance, fetch Perl docs from the Formatter table and compile them the way \s-1AUTOLOAD\s0 does." .IX Subsection "How can I get my HTML files to be converted into Perl code which, as a whole, could then be compiled as function so that I could, for instance, fetch Perl docs from the Formatter table and compile them the way AUTOLOAD does." Embperl cannot covert your \s-1HTML\s0 into one piece of Perl-code, but you can wrap the call to Execute into a Perl function and let \s-1AUTOLOAD\s0 call it. .SS "I have an \s-1HTML\s0 page which is dynamically generated at runtime and should be post-processed by Embperl. How can I do this?" .IX Subsection "I have an HTML page which is dynamically generated at runtime and should be post-processed by Embperl. How can I do this?" .IP "1.) Generate the page within a normal CGI/Apache::Registry script and put the result into a scalar \- then you can call HTML::Embperl::Execute to post-process your document. Execute can either send the document to the browser or put it into another scalar for further processing." 4 .IX Item "1.) Generate the page within a normal CGI/Apache::Registry script and put the result into a scalar - then you can call HTML::Embperl::Execute to post-process your document. Execute can either send the document to the browser or put it into another scalar for further processing." .PD 0 .IP "2.) Use \s-1EMBPERL_INPUT_FUNC\s0 (1.1b1 and above). With this configuration directive, you can specify a custom input function which reads the \s-1HTML\s0 source from the disk or even from a database. Embperl also provides the function ProxyInput, which allows you to get input from another web server altogether." 4 .IX Item "2.) Use EMBPERL_INPUT_FUNC (1.1b1 and above). With this configuration directive, you can specify a custom input function which reads the HTML source from the disk or even from a database. Embperl also provides the function ProxyInput, which allows you to get input from another web server altogether." .IP "3.) Look at the module Apache::EmbperlChain, which is able to chain multiple modules, including Embperl, together." 4 .IX Item "3.) Look at the module Apache::EmbperlChain, which is able to chain multiple modules, including Embperl, together." .PD .SS "How can I customise the header that Embperl is sending?" .IX Subsection "How can I customise the header that Embperl is sending?" You can write it as .PP .Vb 1 \& .Ve .PP (Embperl will automatically insert all meta http-equiv tags into the http header) .PP or use \f(CW%http_headers_out\fR .PP .Vb 1 \& [\- $http_headers_out{\*(AqContent\-Type\*(Aq} = \*(Aqtext/html\*(Aq \-] .Ve .PP or (only when running under mod_perl) you can use .PP .Vb 1 \& [\- $req_rec \-> content_type (\*(Aqtext/html\*(Aq) \-] .Ve .SS "Can I use Embperl to send cookies?" .IX Subsection "Can I use Embperl to send cookies?" Yes. Embperl sends its own headers, so all you have to do to send cookies is to remember to print an additional header. .PP Example Code: .IP "1.) in documents, add" 4 .IX Item "1.) in documents, add" .Vb 1 \& .Ve .ie n .IP "2.) or use %http_headers_out" 4 .el .IP "2.) or use \f(CW%http_headers_out\fR" 4 .IX Item "2.) or use %http_headers_out" .Vb 1 \& [\- $http_headers_out{\*(AqSet\-Cookie\*(Aq} = "$cookie=$value" \-] .Ve .IP "3.) or \- using mod_perl's functionality \- use" 4 .IX Item "3.) or - using mod_perl's functionality - use" .Vb 1 \& [\- $req_rec \-> header_out("Set\-Cookie" => "$cookie=$value"); \-] .Ve .PP \&\s-1NOTE:\s0 You make also take a look at Embperls (1.2b2 and above) ability to handle sessions for you inside the \f(CW%udat\fR and \f(CW%mdat\fR hashes. .SS "Can I do a Redirect with Embperl?" .IX Subsection "Can I do a Redirect with Embperl?" The following way works with mod_perl and as cgi: .PP .Vb 1 \& [\- $http_headers_out{\*(AqLocation\*(Aq} = "http://www.ecos.de/embperl/" \-] .Ve .PP the status of the request will automatically set to 301. .PP or use the mod_perl function Apache::header_out. .PP Example Code: .PP .Vb 3 \& [\- \& use Apache; \& use Apache::Constants qw(REDIRECT); \& \& $req_rec\->header_out("Location" => "http://$ENV{HTTP_HOST}/specials/"); \& $req_rec\->status(REDIRECT); \& \-] .Ve .PP If there is nothing more to do on this page, you may call \f(CW\*(C`exit\*(C'\fR directly after setting the status. .SS "Can I serve random GIFs with Embperl? (Will Lincoln Stein's \s-1GD\s0.pm module work with Embperl??)" .IX Subsection "Can I serve random GIFs with Embperl? (Will Lincoln Stein's GD.pm module work with Embperl??)" As always, there is more than one way to do this \- especially as this is more of a question of how you are coding your \s-1HTML\s0 than how you are coding your Embperl. .PP Here are some ideas: .IP "1.) You could include an \s-1IMG\s0 tag which points to your cgi-bin, where a regular \s-1CGI\s0 script serves the graphics." 4 .IX Item "1.) You could include an IMG tag which points to your cgi-bin, where a regular CGI script serves the graphics." .PD 0 .IP "2.) You could be running Apache::Registry, which can generate on-the-fly GIFs using \s-1GD.\s0 (This is just the same as if you were including the \s-1GD\s0 image from a static page or from another \s-1CGI\s0 script, but it allows all of the appropriate logic to live in a single document, which might be appropriate for some Embperl users)." 4 .IX Item "2.) You could be running Apache::Registry, which can generate on-the-fly GIFs using GD. (This is just the same as if you were including the GD image from a static page or from another CGI script, but it allows all of the appropriate logic to live in a single document, which might be appropriate for some Embperl users)." .PD .PP If you think of another way, or come up with some sample code, I'd love to hear from you, so that I could add it to the \s-1FAQ...\s0 .ie n .SS "Can I use Embperl as a template for forms? Can I make form values persist (like with ""vanilla"" \s-1CGI\s0)? Does Embperl rewrite my template file so that parameters of things like \s-1INPUT/TEXTAREA/SELECT\s0 persist?" .el .SS "Can I use Embperl as a template for forms? Can I make form values persist (like with ``vanilla'' \s-1CGI\s0)? Does Embperl rewrite my template file so that parameters of things like \s-1INPUT/TEXTAREA/SELECT\s0 persist?" .IX Subsection "Can I use Embperl as a template for forms? Can I make form values persist (like with vanilla CGI)? Does Embperl rewrite my template file so that parameters of things like INPUT/TEXTAREA/SELECT persist?" Yes. Your page design staff should just be able to say and let the default attributes of \*(L"foo\*(R" be defined elsewhere \- for instance in a settings file. In this case, \f(CW%fdat\fR should be pre-set with your default values. Setting \f(CW$fdat\fR{foo} = \*(L"abc\*(R" will cause Embperl to change the above code to . .SS "Does Embperl automatically add \s-1HIDDEN\s0 fields?" .IX Subsection "Does Embperl automatically add HIDDEN fields?" The [$hidden$] metacommand creates hidden fields for every entry in \f(CW%fdat\fR which was not used by any other input tag so far. .PP You can also try something like this: .PP .Vb 4 \& [\- \& $fdat{foo} = "abc" ; \& $fdat{bar} = "xyz" ; \& \-] \& \& \& \& \& [$hidden$] .Ve .PP and Embperl will create: .PP .Vb 2 \& \& .Ve .PP For a list of all possible metacommands, see the section on Meta-Commands in the Embperl documentation. .SS "What about security? Is Embperl Secure?" .IX Subsection "What about security? Is Embperl Secure?" Just like anything else, Embperl is as secure as you make it. Embperl incorporates Safe.pm, which will make it impossible to accidentally access other Packages \- it also permits the Administrator to disable Perl opcodes, etc. .PP For more on security, please see \*(L"(Safe\-)Namespaces and opcode restrictions\*(R" in Embperl in the Embperl documentation. .SS "Is there any plan to make Embperl an Object so someone could subclass it and override certain of its methods? (For example, I'd like to let it parse the file for me, but then let me control the manipulation of the form tags.)" .IX Subsection "Is there any plan to make Embperl an Object so someone could subclass it and override certain of its methods? (For example, I'd like to let it parse the file for me, but then let me control the manipulation of the form tags.)" Embperl is going to be an Object from version 1.2b1. This, among other things, make it re-entrant, so that you will be able to call Execute from within an Embperl page. It will also mean that Embperl will come with hooks, which will allow you to alter or change the way Embperl processes code. The details have not all been worked out yet, but I'm working on it... :) .SS "Are Embperl routines currently pre-compiled or even cached, or are only fragments cached?" .IX Subsection "Are Embperl routines currently pre-compiled or even cached, or are only fragments cached?" All embedded Perl code is compiled the first time it is executed and cached for later use. The second time the code is executed, only the precompiled p\-code is called. .PP Every code block is compiled as a single subroutine. The \s-1HTML\s0 text between the Perl block is still read from the file. .SS "Why are Perl blocks broken up into single subroutines?" .IX Subsection "Why are Perl blocks broken up into single subroutines?" .IP "1.) It makes it easier to process the \s-1HTML\s0 tags between the Perl blocks \- this gives you more control over what's happening" 4 .IX Item "1.) It makes it easier to process the HTML tags between the Perl blocks - this gives you more control over what's happening" .PD 0 .IP "2.) If you compiled _everything_ to Perl, you would hold all of the \s-1HTML\s0 text in memory, and your Apache child processes would grow and grow... But often-accessed documents are still held in memory by your os disk cache, which is much more memory-efficient." 4 .IX Item "2.) If you compiled _everything_ to Perl, you would hold all of the HTML text in memory, and your Apache child processes would grow and grow... But often-accessed documents are still held in memory by your os disk cache, which is much more memory-efficient." .IP "3.) There is only so far that you can go with precompiling until you reach the point of diminishing returns. My guess is that converting dynamic tables and other \s-1HTML\s0 processing to Perl at this point in Embperl's development would actually slow down operation." 4 .IX Item "3.) There is only so far that you can go with precompiling until you reach the point of diminishing returns. My guess is that converting dynamic tables and other HTML processing to Perl at this point in Embperl's development would actually slow down operation." .PD .SS "Can I pass \s-1QUERY_STRING\s0 information to an HTML::Embperl::Execute call?" .IX Subsection "Can I pass QUERY_STRING information to an HTML::Embperl::Execute call?" With Embperl 1.0 and higher, you can do this. \s-1QUERY_STRING\s0 is set as \&\f(CW$ENV\fR{\s-1QUERY_STRING\s0} by default. Alternatively, you can use the fdat parameter to pass values to \f(CW%fdat\fR. .SS "How to include other files into Embperl pages?" .IX Subsection "How to include other files into Embperl pages?" I am using embedded Perl on my site and am curious if I can use it for server side includes. I want to embed the contents of file x.html into file y.html such that whenever I change x.html, displaying y.html will also reflect this change. How do I do it using embedded perl? .PP You need Embperl 1.2b4 or above. Then you can say inside of y.html: .PP .Vb 1 \& [\- Execute (\*(Aqx.html\*(Aq) \-] .Ve .SS "EmbPerl iteration without indexing" .IX Subsection "EmbPerl iteration without indexing" I have a rather large table in a database which I'd like to display using EmbPerl. All of the examples show a process of fetching all the data first, then iterating through it using \f(CW$row\fR and \f(CW$col\fR, like this: .PP .Vb 8 \& [\- \& $sth = $dbh \-> prepare ("select * from $comptbl order by SubSystem"); \& $sth \-> execute; \& $dref = $sth \-> fetchall_arrayref; \& \-] \& \& ... $dref \-> [$row][0] ... \&
.Ve .PP I'd prefer to fetch the data one row at a time, how can I do this? .PP For solution 1 you may write .PP .Vb 5 \& \& [$while $rref = $sth \-> fetch $] \& .... \& [$endwhile$] \&
.Ve .PP Solution 2 should work like this .PP .Vb 5 \& \& [\- $dummy = $row ; $rref = $sth \-> fetch \-] \& .... \& \&
.Ve .PP The table ends when the expression where \f(CW$row\fR is used in some way returns . So also there is no releation between \f(CW$row\fR and the fetch, both conditions are met. .SS "How to display arrays with undef values in it?" .IX Subsection "How to display arrays with undef values in it?" I'm doing a search on a table where some of the columns have \s-1NULL\s0 and non-NULL values. DBIx::Recordset has no problem reading this values The problem is that I then tried to print these values out in a table using Embperl's table feature, like this. .PP .Vb 5 \& \& \& \& \& \& \& The problem is that I got 5 rows instead of the 15 that I was expected. I \& have been trying all kinds of tweaks to the arguments to the Search \& function and getting nowwhere, until I re\-read the Embperl docs. Embperl \& will not print out a table row if one of the columns has an \& expression that \& is undefined. This is a problem since DBIx::Recordset (and DBI) \& natually uses undef to represent a NULL value for a column. So I made a \& slight modification to my embperl code. \& \&
$set[$row]{column_name1}$set[$row]{column_nameN}
\& \& \& . . . \& \& .Ve .PP Now all 15 rows appear as expected, with \*(L"\s-1UNDEF\*(R"\s0 representing the \s-1NULL\s0 values in the database. .PP Another way top solve you problem may be: .PP .Vb 7 \&
defined($set[$row]{column_name1}) ? $set[$row]{column_name1} : \& "UNDEF"$set[$row]{column_nameN} ? $set[$row]{column_nameN} : "UNDEF"
\& \& [\- $r = $set[$row] \-] \& \& . . . \& \& .Ve .PP This will only refer one time to \f(CW$row\fR and the expression is defined, as long as the row could be fetched from the db. All \s-1NULL\s0 fields will be displayed as empty table cells. .SH "Escaping & Unescaping" .IX Header "Escaping & Unescaping" .SS "Escaping & Unescaping Input" .IX Subsection "Escaping & Unescaping Input" By default, Embperl removes all \s-1HTML\s0 tags from the Perl source. It does this because many high-end \s-1WYSIWYG HTML\s0 Editors (like \s-1MS\s0 Front Page) insert \s-1HTML\s0 tags like <\s-1FONT\s0> and <\s-1COLOR\s0> in rather random places (like in the middle of your Perl code). This Embperl feature keeps things like .PP .Vb 2 \& [\- $var = 1;
\& $foo = 2 \-] .Ve .PP permissible, so that you can enter Perl code while you mark up pages in an editor, all at once. In this example, Embperl would remove the unnecessary
tag and, therefore, make Perl happy. And if Perl is happy, we are all happy. .PP It is not difficult to change this behavior, if you are the kind of person who codes \s-1HTML\s0 in an ascii editor (like vi or emacs). .PP If you use a high-level \s-1HTML\s0 editor, you shouldn't have any problems with input escaping, because the editor will, for example, write a '<' as \&'<' in the \s-1HTML\s0 code. Embperl translates this back to '<' and therefore it knows that this wasn't an \s-1HTML\s0 tag which should be removed. .PP Problems with input escaping only occur if you use an ascii editor. Then you will need to escape input (see the next section for details on how to do this). .PP To see the exact steps taken by Embperl to process a Perl-laden document, please see the section Inside Embperl in the Embperl documentation. .SS "Ways To Escape Input:" .IX Subsection "Ways To Escape Input:" .IP "1. Escape it \-> \e

" 4 .IX Item "1. Escape it ->

" \&\s-1NOTE:\s0 Inside double quotes you will need to use \e\e (double backslash), since Perl will remove the first Escape itself. .Sp Example: In most cases '\e

' but inside double-quotes \*(L"\e\e\*(R" .IP "2. Turn off Escaping for all input by setting the optRawInput in \s-1EMBPERL_OPTIONS\s0" 4 .IX Item "2. Turn off Escaping for all input by setting the optRawInput in EMBPERL_OPTIONS" .PD 0 .IP "3. Learn to avoid using \s-1HTML\s0 tags inside Perl code. Once you get the hang of it, you'll love it." 4 .IX Item "3. Learn to avoid using HTML tags inside Perl code. Once you get the hang of it, you'll love it." .PD .PP Here is one example of how to do it: .PP .Vb 2 \& [\- $output = "Hello world" \-] \& [+ $output +] .Ve .PP write .PP .Vb 1 \& [\- $output = "Hello world" \-] .Ve .PP this outputs .PP .Vb 1 \& Hello world .Ve .PP or .PP .Vb 1 \& [+ $output +] .Ve .PP this outputs .PP .Vb 1 \& Hello world .Ve .PP And here is another example of how to do it: .PP .Vb 10 \& [\- \& @a = (\*(Aqa\*(Aq, \*(Aqb\*(Aq, \*(Aqc\*(Aq) ; \& foreach $i (0..2) \& { \& $output. = "" ; \& } \& \-] \&
[+ $r \-> {column_name1} +] [+ $r \-> {column_nameN} +]
Row $a[$i]
\& [+ $output +] \&
.Ve .PP The output here would be: .PP .Vb 1 \& Row aRow bRow c
.Ve .PP The Embperl version is .PP .Vb 6 \& [\- \& @a = (\*(Aqa\*(Aq, \*(Aqb\*(Aq, \*(Aqc\*(Aq) ; \& \-] \& \& " ; \&
Row [+ $a[$row] +]
.Ve .PP The output will be .PP .Vb 5 \& \& " ; \& " ; \& " ; \&
Row a
Row b
Row c
.Ve .PP And another: This elegant solution shows you how to take advantage of Embperl's ability to create dynamic tables: .PP .Vb 2 \& [\- \& use DBI; \& \& my $dbh = \& DBI\->connect("DBI:mysql:database:localhost","Username","Password") || \& die($!); \& \& $hstmt = $dbh\->prepare("select ID, Heading from Shops order by Heading"); \& $hstmt\->execute(); \& $dat = $hstmt\->fetchall_arrayref() ; \& $hstmt\->finish(); \& $dbh\->disconnect(); \& \-] \& \& \&
[+ $$dat[$row][$col] +]
.Ve .PP This \s-1HTML\s0 code will then display the contents of the whole array. .SS "Escaping & Unescaping Output" .IX Subsection "Escaping & Unescaping Output" Embperl will also escape the output \- so

will be translated to <H1> .PP To see the exact steps taken by Embperl to process a Perl-laden document, please see Inside Embperl in the Embperl documentation. .SS "Ways To Escape Output:" .IX Subsection "Ways To Escape Output:" .IP "1.) Escape it \-> \e\e

" 4 .IX Item "1.) Escape it ->

" .Vb 2 \& (You need a double backslash \e\e, because \& the first one is removed by Perl and the second by Embperl. .Ve .ie n .IP "2.) set $escmode = 0 \-> [\- $escmode = 0 ; \-]" 4 .el .IP "2.) set \f(CW$escmode\fR = 0 \-> [\- \f(CW$escmode\fR = 0 ; \-]" 4 .IX Item "2.) set $escmode = 0 -> [- $escmode = 0 ; -]" .PD 0 .IP "3.) set SetEnv \s-1EMBPERL_ESCMODE 0\s0 in your srm.conf" 4 .IX Item "3.) set SetEnv EMBPERL_ESCMODE 0 in your srm.conf" .PD .SH "Debugging" .IX Header "Debugging" .SS "I am having a hard time debugging Embperl code" .IX Subsection "I am having a hard time debugging Embperl code" Have you, umm, checked the error log? ;) .PP Have you tried setting debug flags higher by resetting \s-1EMBPERL_DEBUG\s0 in the server config files? (And still higher? :) .PP dbgMem isn't usually very useful as it always outputs a lot of allocation. dbgFlushLog and dbgFlushOutput should be used if (and only if) you are debugging SIGSEGVs. .PP For easy debugging, you can tell Embperl to display a link at the top of each page to your log file. Then every error displayed in an error page is a link to the corresponding position in the logfile, so you can easily find the place where something is going wrong .PP For more on using \s-1HTML\s0 links to the Embperl error log, see \&\*(L"\s-1EMBPERL_DEBUG\*(R"\s0 in Embperl in the Embperldocs. .SS "Embperl is running slow." .IX Subsection "Embperl is running slow." There are some debugging settings which may cause Embperl to drastically slow down. If you are done with debugging, set debugging bits back to normal. .PP Also, using dbgFlushLog and dbgFlushOutput will make execution much slower. These are only intended for debugging SIGSEGVs. .PP Never set all debugging bits! .SS "How can I improve Embperl's performance?" .IX Subsection "How can I improve Embperl's performance?" .IP "1.) Load Embperl at server startup. This will cause \s-1UNIX\s0 systems to only allocate memory once, and not for each child process. This reduces memory use, especially the need to swap additional memory." 4 .IX Item "1.) Load Embperl at server startup. This will cause UNIX systems to only allocate memory once, and not for each child process. This reduces memory use, especially the need to swap additional memory." .PD 0 .IP "2.) Disable all unneeded debugging flags. You should never set dbgFlushLog dbgFlushOutput, dbgMem and dbgEvalNoCache in a production environment." 4 .IX Item "2.) Disable all unneeded debugging flags. You should never set dbgFlushLog dbgFlushOutput, dbgMem and dbgEvalNoCache in a production environment." .IP "3.) You may also want to take a look at the available options you can set via \s-1EMBPERL_OPTIONS.\s0 For example optDisableChdir, will speed up processing because it avoid the change directory before every request." 4 .IX Item "3.) You may also want to take a look at the available options you can set via EMBPERL_OPTIONS. For example optDisableChdir, will speed up processing because it avoid the change directory before every request." .PD .SH "Customizing" .IX Header "Customizing" .SS "How can I fiddle with the default values? How can I override or alter this or that behavior?" .IX Subsection "How can I fiddle with the default values? How can I override or alter this or that behavior?" Usually, defaults are set in a way that is likely to make most sense for a majority of users. As of version 1.0, Embperl allows much more flexibility in tweaking your own default values than before. Take a look at \s-1EMBERPL_OPTIONS.\s0 .SS "I'd like to (temporarily) disable some of Embperl's features. What can be customized?" .IX Subsection "I'd like to (temporarily) disable some of Embperl's features. What can be customized?" .IP "1.) Use optDisableHtmlScan to disable processing of html tags. If this is set, Embperl will only pay attention to these types of constructs:" 4 .IX Item "1.) Use optDisableHtmlScan to disable processing of html tags. If this is set, Embperl will only pay attention to these types of constructs:" [+/\-/!/$ .... $/!/\-/+] .IP "2.) optDisableTableScan, optDisableInputScan and optDisableMetaScan can be used to disable individual parts of \s-1HTML\s0 processing." 4 .IX Item "2.) optDisableTableScan, optDisableInputScan and optDisableMetaScan can be used to disable individual parts of HTML processing." You may set these flags in your server config, or at runtime: .Sp .Vb 3 \& [+ $optDisableHtmlScan = 1 +] \& foo
\& [+ $optDisableHtmlScan = 0 +] .Ve .SS "How can I disable auto-tables?" .IX Subsection "How can I disable auto-tables?" Set optDisableTableScan in \s-1EMBPERL_OPTIONS\s0 .ie n .SS "How can I change predefined values like $escmode from my Toolbox module?" .el .SS "How can I change predefined values like \f(CW$escmode\fP from my Toolbox module?" .IX Subsection "How can I change predefined values like $escmode from my Toolbox module?" .Vb 1 \& $HTML::Embperl::escmode = 0 ; .Ve .PP Predefined values in Embperl are simply aliases for \f(CW$HTML::Embperl::foo\fR (for instance, \f(CW$escmode\fR is an alias for \f(CW$HTML::Embperl::escmode\fR) .SS "How can I customize the header that Embperl is sending?" .IX Subsection "How can I customize the header that Embperl is sending?" You'll find the answer to this and many other header issues in the \*(L"Common Questions\*(R" section. .SS "How can I use a different character set? \s-1ASCII\s0 values over 128 are showing up as ? (question marks)!" .IX Subsection "How can I use a different character set? ASCII values over 128 are showing up as ? (question marks)!" This is caused by the translation of characters to \s-1HTML\s0 escapes. Embperl translates them to escapes which are then sometimes not understood by the browser, which may display a \*(L"?\*(R" instead, because it is using the wrong character set. .PP If you want to use the escaping features of Embperl in this case, you have to adapt the file \f(CW\*(C`epchar.c\*(C'\fR to your character set. .PP The distribution contain already an \f(CW\*(C`epchar.c.iso\-latin\-2\*(C'\fR from Jiri Novak which is an replacement for epchar.c for the iso\-8859\-2 (iso\-latin\-2) character set. If you want to use iso\-latin\-2, simply renmae \f(CW\*(C`epchar.c.iso\-latin\-2\*(C'\fR to \f(CW\*(C`epchar.c\*(C'\fR. There is also an file \f(CW\*(C`epchar.c.min\*(C'\fR from Sangmook Yi, which leaves all chars above 128 untouched, which is especially useful for two byte charsets. .PP This file contains three tables: .PP Char2Html [] Convert characters to html escape .PP Char2Url [] Convert characters to url escapes (do not change this one!!) .PP Html2Char [] Convert html escapes to characters .PP You need to change the first and the last tables. Do not change the second table!! .PP Please make sure Char2Html contains one entry (and only one entry) for each of the 256 ascii codes (with none left undefined) in the right order, and that Html2Char is sorted by html escape. .PP If somebody generates new tables for national character sets, please send a copy to the author, so it can be included it in future versions of Embperl. .SH "Optimizing & Fine-Tuning" .IX Header "Optimizing & Fine-Tuning" .SS "How can I be sure that Embperl is re-compiling my page template (and the Perl blocks contained in it) only when needed, and not each time?" .IX Subsection "How can I be sure that Embperl is re-compiling my page template (and the Perl blocks contained in it) only when needed, and not each time?" As long as your input file's time stamp stays the same, Embperl will only compile the script the first time it's called. When you use the Execute function, Embperl will recompile the script only if the input file and mtime paramenters have changed since the last time the script was called. .PP You can verfiy this by setting dbgDefEval. Now, every time a Perl block is compiled, Embperl logs a line starting with \s-1DEF:.\s0 You will see this line only on the first request. The cached Perl blocks are stored as a set of subroutines in the namespace of the document. (HTML::Embperl::DOC::_ is the default) Look at the logfile to see the actual name. .SS "How can I pre-compile pages, so that each httpd child doesn't have to have its own separate copies of the pre-compiled pages?" .IX Subsection "How can I pre-compile pages, so that each httpd child doesn't have to have its own separate copies of the pre-compiled pages?" To pre-compile pages, just call Execute once for every file at server startup in your startup.pl file. .SS "In what namespace does Embperl store pre-compiled data?" .IX Subsection "In what namespace does Embperl store pre-compiled data?" The cached Perl blocks are stored as a set of subroutines in the namespace of the document. (HTML::Embperl::DOC::_ for default) Look at the logfile to see the actual name. .SS "I have both Embperl and ordinary Perl processes running. The docs say that Embperl uses a \s-1CGI\s0.pm instance in its own internal processing, but they don't say how to control it. How can I get Embperl to use *my* \s-1CGI\s0.pm object instead of creating its own?" .IX Subsection "I have both Embperl and ordinary Perl processes running. The docs say that Embperl uses a CGI.pm instance in its own internal processing, but they don't say how to control it. How can I get Embperl to use *my* CGI.pm object instead of creating its own?" Embperl only creates a \s-1CGI\s0 objects to process multipart form data (from fileupload). In all other cases Embperl doesn't use \s-1CGI\s0.pm. There is no way to change this behaviour, or access the internal \s-1CGI\s0 object in case of file-uploads. .SH "Additional Help" .IX Header "Additional Help" .SS "Where can I get more help?" .IX Subsection "Where can I get more help?" You can get free support on the mod_perl mailing list. If you need commercial support (with a guarantee for response time or a solution) for Embperl, or if you want a web site where you can run your Embperl/mod_perl scripts without setting up your own web server, please send email to info@ecos.de. .PP Please also see the section \*(L"Support\*(R" in Embperl in the Embperl documentation. .SH "SEE ALSO" .IX Header "SEE ALSO" some links here .SH "AUTHOR" .IX Header "AUTHOR" Gerald Richter .PP Edited by Nora Mikes