Config(3pm)
โจ NAME โจ
okay bestie, welcome to Config(3pm) โ User Contributed Perl Documentation. This page is Embperl::Config โ Embperl configuration and calling. ๐ No cap, this is the whole vibe: how Embperl gets configured and how you call it. ๐ซถ
๐ฆ Operating-Modes ๐ฆ
Embperl can operate in one of four modes:
mod_perlโ the mostly used way. You run Embperl together withmod_perland Apache. This gives the best performance and the most possibilities. ๐CGI/FastCGIโ when you want to run Embperl on a machine that doesn't havemod_perl, you can run it as a normal CGI script. Due to the overhead of CGI, this mode is much slower. To get better performance, consider using Embperl together with FastCGI. (http://www.fastcgi.com). ๐ขโก๏ธ๐Offlineโ you can use Embperl on the command line. Useful for generating static content out of dynamic pages, and sometimes helpful for testing. ๐ฅ๏ธโจ- Call it from other Perl programs โ if you have your own application and want to use Embperl's capabilities, call
Embperl::Execute. This lets you build your own application logic and use Embperl possibilities for rendering content. ๐
๐ป mod_perl ๐ป
To use Embperl under mod_perl, you must have installed Apache and mod_perl on your system. Then add some directives to your httpd.conf to load Embperl and add "Embperl" as the "PerlHandler". The following directives cause all files with extension epl to be handled by Embperl:
PerlModule Embperl
AddType text/html .epl
<Files *.epl>
SetHandler perl-script
PerlHandler Embperl
Options ExecCGI
</files>
Another possibility is to have all files under a special location processed by Embperl:
PerlModule Embperl
Alias /embperl /path/to/embperl/eg
<Location /embperl/x>
SetHandler perl-script
PerlHandler Embperl
Options ExecCGI
</Location>
In this setup, make sure non-Embperl files like images don't get served from this directory. ๐ผ๏ธ๐ โโ๏ธ
For mod_perl 2.0 you additionally need to load the dynamic object library of Embperl. This is necessary so Embperl is loaded early enough to register the configuration directives with Apache. After installing, search underneath your Perl site directory for the library. On Unix it is mostly called Embperl.so; on Windows it is called "Embperl.dll". Now add the following line to your httpd.conf before any of the Embperl configuration directives, but after mod_perl.so is loaded:
LoadModule embperl_module /path/to/perl/site/lib/Embperl/Embperl.so
To use Embperl::Object, use "Embperl::Object" as "PerlHandler":
<Location /foo>
Embperl_AppName unique-name
Embperl_Object_Base base.htm
Embperl_UriMatch "\.htm.?|\.epl$"
SetHandler perl-script
PerlHandler Embperl::Object
Options ExecCGI
</Location>
Additionally, you can set up other parameters for Embperl::Object. If you do so inside a container (like <Location, <Directory>, <Files>), you need to set Embperl_AppName to a unique-name (the actual value doesn't matter). The Embperl_UriMatch makes sure that only files of the requested type are served by Embperl::Object, while all others are served by Apache as usual. ๐ฏ
For more information see: perldoc Embperl::Object.
Embperl accepts a lot of configuration directives to customize its behaviour. See the next section for a description. ๐
NOTE: Ifmod_perlis statically linked into Apache, you can not useClearModuleListin yourhttpd.conf. โ ๏ธ
๐ Preloading pages ๐
To optimize memory usage, you can preload your pages during initialization. If you do so, they get loaded into the parent process and the memory will be shared by all child processes. ๐ง ๐
To let Embperl preload your files, you have to supply all the filenames into the key preloadfiles of the hash %initparam, before you load Embperl.
Example:
BEGIN
{
$Embperl::initparam{preloadfiles} =
[
'/path/to/foo.epl',
'/path/to/bar.epl',
{ inputfile => "/path/to/other.epl", input_escmode => 7 },
] ;
}
use Embperl ;
As you see for the third file, it is also possible to give a hashref and supply the same parameters like Execute accepts (see below). ๐ฆ
NOTE: Preloading is not supported under Apache 1.3 whenmod_perlis loaded as DSO. To use preloading under Apache 1.3 you need to compilemod_perlstatically into Apache. โ ๏ธ
๐ CGI/FastCGI ๐
To use this mode you must copy embpcgi.pl to your cgi-bin directory. You can invoke it with the URL http://www.domain.xyz/cgi-bin/embpcgi.pl/url/of/your/document. ๐
The /url/of/your/document will be passed to Embperl by the web server. Normal processing (aliasing, etc.) takes place before the URI makes it to PATH_TRANSLATED.
If you are running the Apache httpd, you can also define embpcgi.pl as a handler for a specific file extension or directory.
Example of Apache "httpd.conf":
<Directory /path/to/your/html/docs>
Action text/html /cgi-bin/embperl/embpcgi.pl
</Directory>
NOTE: Via CGI Scripts it may be possible to bypass some of the Apache setup. To avoid this use Embperl_Allow to restrict access to the files which should be processed by Embperl. ๐
For Embperl::Object you have to use epocgi.pl instead of embpcgi.pl.
You can also run Embperl with FastCGI; in this case use embpfastcgi.pl as the cgi script. You must have FCGI.pm installed. โก
๐ฅ๏ธ Offline ๐ฅ๏ธ
Run Embperl from the command line using embpexec.pl on unix and embpexec.bat on windows:
embpexec.pl [options] htmlfile [query_string]
embpexec.bat [options] htmlfile [query_string]
htmlfileโ the full pathname of the source file which should be processed by Embperl.query_stringโ optional. Has the same meaning as the environment variableQUERY_STRINGwhen invoked as a CGI script. That is,QUERY_STRINGcontains everything following the first?in a URL.<query_string>should be URL-encoded. The default is no query string.
Options:
-o outputfileโ optional. Gives the filename to which the output is written. The default isstdout.-l logfileโ optional. Gives the filename of the logfile. The default is/tmp/embperl.logon unix and\embperl.logon windows.-d debugflagsโ optional. Specifies the level of debugging (what is written to the log file). The default is nothing. See"EMBPERL_DEBUG"for exact values.-t optionsโ see"EMBPERL_OPTIONS"for option values.-s syntaxโ defines the syntax of the source. See"EMBPERL_SYNTAX".-p paramโ gives a value which is passed in the@paramarray to the executed page. Can be given multiple times.-f fdat valueโ gives a name/value pair which is passed in the%fdathash to the executed page. Can be given multiple times.
๐ช By calling Embperl::Execute (\%param) ๐ช
"Execute" can be used to call Embperl from your own modules/scripts (for example from an Apache::Registry or CGI script) or from within another Embperl page to nest multiple Embperl pages (for example to store a common header or footer in a different file). ๐งฌ
(See eg/x/Excute.pl for more detailed examples)
When you want to use Embperl::Object, call "Embperl::Object::Execute"; when you want Embperl::Mail, call "Embperl::Mail::Execute".
There are two forms you can use for calling Execute. A short form which only takes a filename and optional additional parameters, or a long form which takes a hash reference as its argument.
Execute($filename, $p1, $p2, $pn) ;
This will cause Embperl to interpret the file with the name $filename and, if specified, pass any additional parameters in the array @param (just like @_ in a Perl subroutine). The above example could also be written in the long form:
Execute ({inputfile => $filename,
param => [$p1, $p2, $pn]}) ;
The possible items for the hash of the long form are described in the configuration section and parameter section. ๐
EXAMPLES for Execute:
# Get source from /path/to/your.html and
# write output to /path/to/output'
Embperl::Execute ({ inputfile => '/path/to/your.html',
outputfile => '/path/to/output'}) ;
# Get source from scalar and write output to stdout
# Don't forget to modify mtime if $src changes
$src = '<html><head><title>Page [+ $no +]</title></head>' ;
Embperl::Execute ({ inputfile => 'some name',
input => \$src,
mtime => 1 }) ;
# Get source from scalar and write output to another scalar
my $src = '<html><head><title>Page [+ $no +]</title></head>' ;
my $out ;
Embperl::Execute ({ inputfile => 'another name',
input => \$src,
mtime => 1,
output => \$out }) ;
print $out ;
# Include a common header in an Embperl page,
# which is stored in /path/to/head.html
[- Execute ('/path/to/head.html') -]
๐ Debugging ๐
Starting with 2.0b2, Embperl files can be debugged via the interactive debugger. The debugger shows the Embperl page source along with the correct linenumbers. You can do anything you can do inside a normal Perl program via the debugger, e.g. show variables, modify variables, single step, set breakpoints etc. ๐ต๏ธโโ๏ธ
You can use the Perl interactive command line debugger via:
perl -d embpexec.pl file.epl
Or if you prefer a graphical debugger, try ddd (http://www.gnu.org/software/ddd/). It's a great tool, also for debugging any other perl script:
ddd --debugger 'perl -d embpexec.pl file.epl'
NOTE: embpexec.pl could be found in the Embperl source directory. ๐
If you want to debug your pages while running under mod_perl, Apache::DB is the right thing. Apache::DB is available from CPAN. ๐
๐ Configuration ๐
okay bestie, so configuring Embperl is lowkey giving choose your own adventure ๐ โ there's like a million ways to do it, depending on how you run it. let me break it down fr fr:
- when you run under mod_perl, Embperl adds a whole set of new config directives to the Apache config, so you can just set them in your
httpd.conf. iconic. - when you run Embperl as CGI, it takes the config from environment variables. and for compatibility reasons you can also turn that on under mod_perl by adding
Embperl_UseEnv onin yourhttpd.conf. - when you call Embperl from another Perl program โ by calling the
Executefunction โ you can pass your config along with other params as a hash reference. and if you passuse_env =< 1as a parameter, Embperl will also scan the environment for config info. - last but not least, you can pass config info as options when you run Embperl via
embpexec.plfrom the command line.
and some of these config options are also settable inside the page via the Embperl objects, and you can read the current config from those objects too. so many vibes โจ
and it's not just about how you pass config โ there are also three different contexts: Application, Request, and Component. ๐
- Application โ a set of pages/files that belong together and form the application. Application-level config is the same for all files in that app. this info needs to be known before any request processing happens, so it can't be modified during a request. every application has its own name, and you refer to an app's config just by setting the name of the app to use.
- Request โ config that applies to one request. some of it must be known before the request starts, and some can still be modified during the request.
- Component โ config can be set up before the request, but can also be passed as an argument when you call the component via
Execute.
โจ Embperl_Useenv โจ
- Env:
EMBPERL_USEENV - Method:
$application -> config -> use_env[read only] - Default: off unless running as CGI script
- Since: 2.0b6
Tells Embperl to scan the enviromemt for configuration settings. (yes bestie, the typo is canon, I don't make the rules ๐ซถ)
โจ use_redirect_env โจ
- Method:
$application -> config -> use_redirect_env[read only] - Default: off unless running as CGI script
- Since: 2.0b6
Tells Embperl to scan the enviromemt for configuration settings which have the prefix REDIRECT_. this is normally the case when the request is not the main request, but a subrequest. ๐ฆ
โจ Embperl_Appname โจ
- Env:
EMBPERL_APPNAME - Method:
$application -> config -> app_name[read only] - Since: 2.0b6
Specifies the name for an application. the name is basically used to refer to this application elsewhere in httpd.conf without needing to set up the parameters for the application again. no cap, it's just a nickname for your whole setup. ๐
โจ Embperl_App_Handler_Class โจ
- Env:
EMBPERL_APP_HANDLER_CLASS - Method:
$application -> config -> app_handler_class[read only] - Since: 2.0b6
Embperl will call the init method of the given class at the start of the request, but after all request parameters are set up. this gives the class a chance to do any necessary computation and modify the request parameters before the request is actualy executed. see internationalization for an example. ๐ง
โจ Embperl_Session_Handler_Class โจ
- Env:
EMBPERL_SESSION_HANDLER_CLASS - Method:
$application -> config -> session_handler_class[read only] - Default:
Apache::SessionX - Since:
1.3b3 - See also: Session Handling
Set the class that performs the Embperl session handling. this gives you the possibility to implement your own session handling. main character energy, honestly. ๐
NOTE: the default until1.3.3wasHTML::Embperl::Session, and starting with1.3.4it isApache::SessionX. to get the old session behaviour, set it toHTML::Embperl::Session.
โจ Embperl_Session_Args โจ
- Env:
EMBPERL_SESSION_ARGS - Method:
$application -> config -> session_args[read only] - Since:
1.3b3 - See also: Session Handling
List of arguments for Apache::Session classes. arguments that contain spaces can be quoted. Example:
EMBPERL_SESSION_ARGS "DataSource=dbi:mysql:session UserName=www 'Password=secret word'"
โจ Embperl_Session_Classes โจ
- Env:
EMBPERL_SESSION_CLASSES - Method:
$application -> config -> session_classes[read only] - Since:
1.3b3 - See also: Session Handling
Space separated list of object store and lock manager (and optionally the serialization and id generating class) for Apache::Session (see "Session handling"). ๐
โจ Embperl_Session_Config โจ
- Env:
EMBPERL_SESSION_CONFIG - Method:
$application -> config -> session_config[read only] - Default: given when running
Makefile.PLofApache::SessionX - Since:
1.3.3 - See also: Session Handling
Selects a session configuration from the configurations you have defined when running Apache::SessionX's Makefile.PL. ๐ธ
NOTE: use eitherEMBPERL_SESSION_CONFIGorEMBPERL_SESSION_ARGSandEMBPERL_SESSION_CLASSES. pick a lane bestie, not both. ๐ซถ
โจ Embperl_Cookie_Name โจ
- Env:
EMBPERL_COOKIE_NAME - Method:
$application -> config -> cookie_name[read only] - Default:
EMBPERL_UID - Since:
1.2b4 - See also: Session Handling
Set the name that Embperl uses when it sends the cookie with the session id. ๐ช
โจ Embperl_Cookie_Domain โจ
- Env:
EMBPERL_COOKIE_DOMAIN - Method:
$application -> config -> cookie_domain[read only] - Default: none
- Since:
1.2b4 - See also: Session Handling
Set the domain that Embperl uses for the cookie with the session id.
โจ Embperl_Cookie_Path โจ
- Env:
EMBPERL_COOKIE_PATH - Method:
$application -> config -> cookie_path[read only] - Default: none
- Since:
1.2b4 - See also: Session Handling
Set the path that Embperl uses for the cookie with the session id.
โจ Embperl_Cookie_Expires โจ
- Env:
EMBPERL_COOKIE_EXPIRES - Method:
$application -> config -> cookie_expires[read only] - Default: at the end of the session
- Since:
1.3b5 - See also: Session Handling
Set the expiration date that Embperl uses for the cookie with the session id. you can specify the full date or relativ values. the following forms are all valid times: โฐ
+30s 30 seconds from now
+10m ten minutes from now
+1h one hour from now
-1d yesterday (i.e. "ASAP!")
now immediately
+3M in three months
+10y in ten years time
Thu, 25-Apr-1999 00:40:33 GMT at the indicated time & date
โจ Embperl_Cookie_Secure โจ
- Env:
EMBPERL_COOKIE_SECURE - Method:
$application -> config -> cookie_secure[read only] - Default: at the end of the session
- Since:
2.0b9 - See also: Session Handling
Set the secure flag of the cookie that Embperl uses for the session id. if set, the cookie will only be transferred over a secured connection. ๐ periodt.
โจ Embperl_Log โจ
- Env:
EMBPERL_LOG - Method:
$application -> config -> log[read only] - Default: Unix:
/tmp/embperl.logWindows:/embperl.log
Gives the location of the log file. this will contain information about what Embperl is doing. the amount of information depends on the debug settings (see EMBPERL_DEBUG below). the log output is intended to show what your embedded Perl code is doing and to help debug it. ๐
โจ Embperl_Debug โจ
- Env:
EMBPERL_DEBUG - Method:
$application -> config -> debug
This is a bitmask which specifies what should be written to the log. to specify multiple debugflags, simply add the values together. you can give the value a decimal, octal (prefix 0) or hexadecimal (prefix 0x) value. you can also use the constants defined in Embperl::Constant. the following values are defined: ๐
๐ dbgStd = 1 (0x1)
Show minimum information.
๐ dbgMem = 2 (0x2)
Show memory and scalar value allocation.
๐ dbgEval = 4 (0x4)
Show arguments to and results of evals.
๐ dbgEnv = 16 (0x10)
List every request's environment variables.
๐ dbgForm = 32 (0x20)
List posted form data.
๐ dbgInput = 128 (0x80)
Show processing of HTML input tags.
๐ dbgFlushOutput = 256 (0x100)
Flush Embperl's output after every write. this should only be set to help debug Embperl crashes, as it drastically slows down Embperl's operation. ๐
๐ dbgFlushLog = 512 (0x200)
Flush Embperl's logfile output after every write. this should only be set to help debug Embperl crashes, as it drastically slows down Embperl's operation. ๐
๐ dbgLogLink = 8192 (0x2000)
This feature is not yet implemented in Embperl 2.0!
Inserts a link at the top of each page which can be used to view the log for the current HTML file. see also EMBPERL_VIRTLOG.
Example:
EMBPERL_DEBUG 10477
EMBPERL_VIRTLOG /embperl/log.htm
<Location /embperl/log.htm>
SetHandler perl-script
PerlHandler Embperl
Options ExecCGI
</Location>
๐ dbgDefEval = 16384 (0x4000)
Shows every time new Perl code is compiled.
๐ dbgHeadersIn = 262144 (0x40000)
Log all HTTP headers which are sent from and to the browser.
๐ dbgShowCleanup = 524288 (0x80000)
Show every variable which is undef'd at the end of the request. for scalar variables, the value before undef'ing is logged. ๐ญ
๐ dbgSession = 2097152 (0x200000)
Enables logging of session transactions.
๐ dbgImport = 4194304 (0x400000)
Show how subroutines are imported in other namespaces.
๐ dbgOutput = 0x08000
Logs the process of converting the internal tree strcuture to plain text for output.
๐ dbgDOM = 0x10000
Logs things related to processing the internal tree data structure of documents.
๐ dbgRun = 0x20000
Logs things related to execution of a document.
๐ dbgBuildToken = 0x800000
Logs things related to creating the token tables for source parsing.
๐ dbgParse = 0x1000000
Logs the parseing of the source.
๐ dbgObjectSearch = 0x2000000
Shows how Embperl::Objects searches sourcefiles.
๐ dbgCache = 0x4000000
Logs cache related things. ๐ฆ
dbgCompile=0x8000000โ spills the tea on how the parsed source gets compiled into Perl code โdbgXML=0x10000000โ logs everything XML-processing related ๐ฆdbgXSLT=0x20000000โ logs everything XSLT-processing related โจdbgCheckpoint=0x40000000โ logs stuff about checkpoints, which are used internally while execution happens. Real talk: this is only useful if you have deep knowledge of Embperl internals. Like, deep deep. ๐ณ๏ธ
๐ธ Embperl_Maildebug ๐ธ
- Env:
EMBPERL_MAILDEBUG - Method:
$application -> config -> maildebug - Since: 1.2.1
The debug value that gets passed straight to Net::SMTP. ๐ง
๐ธ Embperl_Mailhost ๐ธ
- Env:
EMBPERL_MAILHOST - Method:
$application -> config -> mailhost - Default:
localhost
Tells you which host the mail-related functions of Embperl use as their SMTP server. ๐
๐ธ Embperl_Mailhelo ๐ธ
- Env:
EMBPERL_MAILHELO - Method:
$application -> config -> mailhelo - Default: chosen by
Net::SMTP - Since: 1.3b4
Which host/domain all mail-related functions use in the HELO/EHLO command. Net::SMTP normally picks a reasonable default, but depending on your installation you might have to set it manually. ๐
๐ธ Embperl_Mailfrom ๐ธ
- Env:
EMBPERL_MAILFROM - Method:
$application -> config -> mailfrom - Default:
www-server@<server_name> - Since: 1.2.1
The email address used as the sender for all mail-related functions. ๐
๐ธ Embperl_Mail_Errors_To ๐ธ
- Env:
EMBPERL_MAIL_ERRORS_TO - Method:
$application -> config -> mail_errors_to
If you set this, all errors get sent to the email address you gave. ๐ญ๐จ
๐ธ Embperl_Mail_Errors_Limit ๐ธ
- Env:
EMBPERL_MAIL_ERRORS_LIMIT - Method:
$application -> config -> mail_errors_limit[read only] - Since: 2.0b6
Do not mail more than <num> errors. Set it to 0 for no limit at all. ๐ฅ
๐ธ Embperl_Mail_Errors_Reset_Time ๐ธ
- Env:
EMBPERL_MAIL_ERRORS_RESET_TIME - Method:
$application -> config -> mail_errors_reset_time[read only] - Since: 2.0b6
Reset the error counter if no error has occurred for <sec> seconds. โฑ๏ธ
๐ธ Embperl_Mail_Errors_Resend_Time ๐ธ
- Env:
EMBPERL_MAIL_ERRORS_RESEND_TIME - Method:
$application -> config -> mail_errors_resend_time[read only] - Since: 2.0b6
Mail errors every <sec> seconds regardless of the error counter. ๐ซถ
๐ธ Embperl_Object_Base ๐ธ
- Env:
EMBPERL_OBJECT_BASE - Method:
$application -> config -> object_base[read only] - Default:
_base.epl - Since: 1.3b1
The name of the base page that Embperl::Objects searches for. ๐
๐ธ Embperl_Object_App ๐ธ
- Env:
EMBPERL_OBJECT_APP - Method:
$application -> config -> object_app - Since: 2.0b6
Filename of the application object that Embperl::Object searches for. That file should hold the Perl code for the application object. There must be no package name given inside the file (because the package is set by Embperl::Object), but the @ISA should point to Embperl::App. If set, this file is searched through the same search path as any content file. After a successful load, the init method is called with the Embperl request object as parameter. The init method can change the parameters inside the request object to influence the current request. ๐
๐ธ Embperl_Object_Addpath ๐ธ
- Env:
EMBPERL_OBJECT_ADDPATH - Method:
$application -> config -> object_addpath - Since: 1.3b1
Extra directories where Embperl::Object searches for pages. ๐๏ธ
This search through the searchpath is always performed if in a call to Execute no path for the file is given.
In httpd.conf or as an environment variable, directories are separated by ";" (on Unix ":" works also). The parameter for "Execute" and the application object method expects/returns an array reference. This path is always appended to the searchpath. ๐ซ
๐ธ Embperl_Object_Reqpath ๐ธ
- Env:
EMBPERL_OBJECT_REQPATH - Method:
$application -> config -> object_reqpath - Since: 2.0b12
Extra directories where Embperl::Object searches for files for the initial request. ๐
If a file is requested but can't be found at the given location, the directories given in this path are additionally searched for the file. This applies only to the initial filename given to Embperl::Object, and not to files called via Execute. ๐
In httpd.conf or as an environment variable, directories are separated by ";" (on Unix ":" works also). The parameter for "Execute" and the application object method expects/returns an array reference.
Example:
if you say
Embperl_Object_Reqpath /a:/b:/c
and you request
/x/index.epl
it will try
/x/index.epl
/a/index.epl
/b/index.epl
/c/index.epl
and take the first one that is found. ๐
๐ธ Embperl_Object_Stopdir ๐ธ
- Env:
EMBPERL_OBJECT_STOPDIR - Method:
$application -> config -> object_stopdir - Since: 1.3b1
The directory where Embperl::Object stops searching for the base page. ๐
๐ธ Embperl_Object_Fallback ๐ธ
- Env:
EMBPERL_OBJECT_FALLBACK - Method:
$application -> config -> object_fallback - Since: 1.3b1
If the requested file isn't found by Embperl::Object, the file given by "EMBPERL_OBJECT_FALLBACK" gets displayed instead. If "EMBPERL_OBJECT_FALLBACK" isn't set, a status 404, NOT_FOUND is returned as usual. If the filename given in "EMBPERL_OBJECT_FALLBACK" doesn't contain a path, it's searched thru the same directories as "EMBPERL_OBJECT_BASE". ๐
๐ธ Embperl_Object_Handler_Class ๐ธ
- Env:
EMBPERL_OBJECT_HANDLER_CLASS - Method:
$application -> config -> object_handler_class - Since: 1.3b1
If you specify this, the template base and the requested page inherit all methods from this class. This class must contain "Embperl::Req" in its @ISA array. ๐
๐ธ Embperl_Useenv ๐ธ
- Env:
EMBPERL_USEENV - Method:
$request -> config -> use_env[read only] - Default: off unless running as CGI script
- Since: 2.0b6
Tells Embperl to scan the environment for configuration settings. ๐
๐ธ use_redirect_env ๐ธ
- Method:
$request -> config -> use_redirect_env[read only] - Default: off unless running as CGI script
- Since: 2.0b6
Tells Embperl to scan the environment for configuration settings that have the prefix "REDIRECT_". This is normally the case when the request isn't the main request but a subrequest. ๐
๐ธ Embperl_Allow ๐ธ
- Env:
EMBPERL_ALLOW - Method:
$request -> config -> allow[read only] - Default: no restrictions
- Since: 1.2b10
If specified, only files matching the given Perl regular expression will be processed by Embperl. All other files return FORBIDDEN. This is especially useful in a CGI environment, because it makes the server more secure. ๐
๐ธ Embperl_Urimatch ๐ธ
- Env:
EMBPERL_URIMATCH - Method:
$request -> config -> urimatch[read only] - Default: process all files
- Since: 2.0b6
If specified, only files matching the given Perl regular expression get processed by Embperl, and all other files get handled by the standard Apache handler. Super handy if you've got Embperl documents and non-Embperl documents (like gifs) living in the same directory. ๐ผ๏ธ
Example:
# Only files which end with .htm will processed by Embperl
EMBPERL_URIMATCH \.htm$
๐ธ Embperl_Multfieldsep ๐ธ
- Env:
EMBPERL_MULTFIELDSEP - Method:
$request -> config -> mult_field_sep[read only] - Default:
\t - Since: 2.0b6
The character used to separate multiple form values that share the same name. ๐
๐ธ Embperl_Path ๐ธ
- Env:
EMBPERL_PATH - Method:
$request -> config -> path[read only] - Since: 1.3b6
Can contain a semicolon-separated (also colon-separated under Unix) file search path. When a file is processed and the filename isn't an absolute path, or doesn't start with ./ (or .\ under Windows), Embperl searches all the specified directories for that file. ๐งญ
There's special handling if the filename starts with any number of "../", i.e. it refers to an upper directory. Then Embperl strips the same number of entries at the start of the searchpath as the filename contains "../". "Execute" and the method of the request object expects/returns an array ref. โจ
๐ธ Embperl_Debug ๐ธ
- Env:
EMBPERL_DEBUG - Method:
$request -> config -> debug
See the application configuration for a description of possible values. ๐
๐ธ Embperl_Options ๐ธ
- Env:
EMBPERL_OPTIONS - Method:
$request -> config -> options
This bitmask specifies some options for the execution of Embperl. To specify multiple options, just add the values together. ๐งฎ
optDisableVarCleanup=1โ disables the automatic cleanup of variables at the end of each request. ๐งนoptDisableEmbperlErrorPage=2โ tells Embperl not to send its own errorpage in case of failure, but instead show as much of the page as possible. Errors are only logged to the log file. Without this option, Embperl sends its own error page showing all the errors that occurred. If you havedbgLogLinkenabled, every error will be a link to the corresponding location in the log file. This option has no effect ifoptReturnErroris set. ๐ซoptReturnError=262144โ with this option set, Embperl sends no output in case of an error. It returns the error back to Apache or the calling program. When running undermod_perl, this gives you the chance to use the ApacheErrorDocumentdirective to show a custom error-document. Inside theErrorDocumentyou can retrieve the error messages with
$errors = $req_rec -> prev -> pnotes('EMBPERL_ERRORS') ;
where $errors is an array reference. (1.3b5+) ๐ญ
optShowBacktrace=0x8000000โ when set, every error message shows not only the sourcefiles but all files from which this file was called byExecute. ๐งต
๐ธ Embperl_Output_Mode ๐ธ
- Env:
EMBPERL_OUTPUT_MODE - Method:
$request -> config -> output_mode - Default:
HTML - Since: 2.0b9
Set the desired output format. 0 for HTML and 1 for XML. If set to XML, all tags generated by Embperl contain a closing slash to conform to XML specs, e.g.
<input type="text" name="foo" />
NOTE: if you setoutput_modeto XML you should also changeescmodeto XML escaping. โ ๏ธ
๐ธ Embperl_Output_Esc_Charset ๐ธ
- Env:
EMBPERL_OUTPUT_ESC_CHARSET
Method: $request -> config -> output_esc_charset [read only]
Default: ocharsetLatin1 = 1
Since: 2.0.2
Okay so this one tells Embperl which charset to assume when it's escaping stuff. Big caveat bestie: you can only set this before the request even starts โ like in httpd.conf or at the very top of the page. Set it halfway down inside the page and you get undefined results. We don't do that. ๐ซ
ocharsetUtf8 = 0โ UTF-8, or literally any charset that isn't one of the known ones. Characters with codes above 128 will not be escaped at all.ocharsetLatin1 = 1โ ISO-8859-1, and this is the default, bestie. When a Perl string has its utf-8 bit set, this mode behaves exactly the same as mode 0, meaning it won't escape anything above 128. ๐ซถocharsetLatin2 = 2โ ISO-8859-2. Same vibe: when a Perl string has its utf-8 bit set, it acts like mode 0 and nothing above 128 gets escaped.
๐ฆ Embperl_Session_Mode ๐ฆ
Env: EMBPERL_SESSION_MODE
Method: $request -> config -> session_mode [read only]
Default: smodeUDatCookie = 1
Since: 2.0b6
This one decides how the session id travels between requests. Options, bestie:
smodeNone = 0โ no session id gets passed, at all, periodt.smodeUDatCookie = 1โ the session id for the user session rides along via cookie. ๐ชsmodeUDatParam = 2โ the session id for the user session gets appended as a parameter to any URL, and gets inserted as a hidden field in any form.smodeUDatUrl = 4โ the session id for the user session is passed as part of the URL. NOT YET IMPLEMENTED!! ๐smodeSDatParam = 0x20โ the session id for the state session gets appended as a parameter to any URL, and gets inserted as a hidden field in any form.
And here's the cute part: you can add the UDat and SDat values together to get both kinds of sessions at once. For example, 0x21 will pass the user session's id inside a cookie and the state session's id as parameters. slay. โจ
๐ธ Embperl_Useenv ๐ธ
Env: EMBPERL_USEENV
Method: $component -> config -> use_env [read only]
Default: off, unless it's running as a CGI script
Since: 2.0b6
Tells Embperl to scan the environment for configuration settings. Yes, the environment. It's giving "look around and pick up what's there". ๐
๐ธ use_redirect_env ๐ธ
Method: $component -> config -> use_redirect_env [read only]
Default: off, unless it's running as a CGI script
Since: 2.0b6
Tells Embperl to scan the environment for config settings that have the prefix "REDIRECT_". This is normally the case when the request isn't the main request but a subrequest. iykyk. ๐ง
๐ Embperl_Package ๐
Env: EMBPERL_PACKAGE
Method: $component -> config -> package
The name of the package where your code gets executed. By default, Embperl generates a unique package name for every file, which is honestly so considerate of it โ it means variables and functions from one file don't start drama with those from another file. (And no cap, any package's variables are still reachable if you use explicit package names.) ๐
๐ฅ Embperl_Debug ๐ฅ
Env: EMBPERL_DEBUG
Method: $component -> config -> debug
Go look at the application configuration for a description of the possible values. That's it, that's the section. ๐
โจ Embperl_Options โจ
Env: EMBPERL_OPTIONS
Method: $component -> config -> options
This bitmask specifies some options for how Embperl executes stuff. Wanna use multiple options? Just add the values together. Math is your friend, bestie. ๐งฎ
optDisableVarCleanup = 1โ disables the automatic cleanup of variables at the end of each request.optDisableEmbperlErrorPage = 2โ tells Embperl not to send its own error page when something fails, and instead show as much of the page as possible. Errors only get logged to the log file. Without this option, Embperl sends its own error page showing all the errors that occurred. And if you havedbgLogLinkenabled, every error is a link straight to the corresponding spot in the log file. Heads up: this option does nothing ifoptReturnErroris set.optReturnError = 262144โ with this set, Embperl sends no output at all when there's an error. It returns the error back to Apache or to the calling program instead. Undermod_perlthis is your moment โจ โ you get to use the ApacheErrorDocumentdirective to show a custom error document. And inside thatErrorDocumentyou can grab the error messages with:
$errors = $req_rec -> prev -> pnotes('EMBPERL_ERRORS') ;
where $errors is an array reference. (1.3b5+)
optShowBacktrace = 0x8000000โ when set, every error message shows not only the source files but all the files from which this file was called byExecute. Receipts for days. ๐งพoptSafeNamespace = 4โ tells Embperl to execute the embedded code in a safe namespace so the code can't touch data or code in any other package. (Peep the chapter about "(Safe-)Namespaces and opcode restrictions" below for the deets.)optOpcodeMask = 8โ tells Embperl to apply an operator mask, which gives you the chance to disallow special (unsafe) opcodes. (Again: see the chapter about "(Safe-)Namespaces and opcode restrictions" below.)optDisableFormData = 256โ this disables the setup of%fdatand@ffld. Embperl won't do anything with the posted form data. Set this when you're usingExecutefrom your perl script and you've already read the form data (via, like,CGI.pmor whatever).optFormDataNoUtf8 = 0x2000000โ by default Embperl checks all the formfields in%fdatto see if they contain valid UTF-8 strings, and if yes, it sets Perl's internal UTF-8 flag. If this option is set, Embperl will never set UTF-8 on any data in%fdat.optAllFormData = 8192โ makes Embperl insert all formfields into%fdatand@ffld, even the empty ones. Empty formfields get inserted with an empty string. Without this option, empty formfields are just straight-up absent from%fdatand@ffld.optRedirectStdout = 16384โ redirectsSTDOUTto the Embperl output stream before every request and resets it afterwards. If it's set, you can use a normal Perlprintinside any Perl block to output data. Without it? You can only output data using the[+ ... +]block, or by printing to the filehandleOUT. Choose wisely. ๐optNoHiddenEmptyValue = 65536(only 1.2b2 and above) โ normally, if there's a value defined in%fdatfor a specific input field, Embperl outputs a hidden input element for it when you usehidden. When this option is set, Embperl won't output a hidden input element for that field when the value is a blank string.optKeepSpaces = 1048576(only 1.2b5 and above)= 0x100000,โ disables the removal of spaces and empty lines from the output. Super useful for sources that aren't HTML. ๐optChdirToSource = 0x10000000(only 2.5 and above) โ changes the current working directory to the directory of the sourcefile before executing the source.
๐ Embperl_Escmode ๐
Env: EMBPERL_ESCMODE
Method: $component -> config -> escmode
Default: 7
Turn HTML and URL escaping on and off. The power is in your hands, bestie. โจ
NOTE: if you wanna output binary data, you must set the escmode to zero. no cap.
For convenience you can change the escmode inside a page by setting the variable $escmode. iconic behaviour honestly.
escXML = 8 (or 15)(2.0b4 and above) โ the result of a Perl expression is always XML-escaped (like>becomes>and'becomes').escUrl + escHtml = 3 (or 7)โ the result of a Perl expression is HTML-escaped (like>becomes>) in normal text, and URL-escaped (like&becomes%26) inside of"A","EMBED","IMG","IFRAME","FRAME"and"LAYER"tags.escUrl = 2 (or 6)โ the result of a Perl expression is always URL-escaped (like&becomes%26).escHtml = 1 (or 5)โ the result of a Perl expression is always HTML-escaped (like>becomes>).escNode = 0โ no escaping takes place. none. zero. nada.escEscape = 4โ add this value to any of the above and Embperl will always perform the escaping. Without it, you can disable escaping by preceding the item that normally gets escaped with a backslash. And yes, that's a handy thing, but it could be very dangerous in situations where content inserted by some user gets redisplayed โ because they can enter arbitrary HTML and slap a backslash in front of it to dodge correct escaping when their input shows up again. ๐ญ
NOTE: you can localize$escmodeinside a[+ +]block, like, to temporarily turn escaping off and output$data. Write:
[+ do { local $escmode = 0 ; $data } +]
๐ง Embperl_Input_Escmode ๐ง
Env: EMBPERL_INPUT_ESCMODE
Method: $component -> config -> input_escmode [read only]
Default: 0
Since: 2.0b6
Tells Embperl how to handle escape sequences it finds in the source. Here's the tea:
0โ don't interpret input (this is the default)1โ unescape html escapes to their characters (i.e.<becomes<) inside of Perl code2โ unescape url escapes to their characters (i.e.%26;becomes&) inside of Perl code3โ unescape html and url escapes, depending on the context
Add 4 to remove html tags inside of Perl code. This is a lifesaver when an html editor inserts html tags like <br> inside your Perl code. ๐
Set EMBPERL_INPUT_ESCMODE to 7 to get the old default of Embperl < 2.0b6.
Set EMBPERL_INPUT_ESCMODE to 0 to get the old behaviour when optRawInput was set.
๐ Embperl_Input_Charset ๐
Env: EMBPERL_INPUT_CHARSET
Method: $component -> config -> input_charset
If you set this to the value "utf8", the source gets interpreted as utf8 encoded, so you can use utf8 literals. It has the exact same effect as adding use utf8 to a normal Perl script. cute! ๐ฆ
โญ Embperl_Top_Include โญ
Env: EMBPERL_TOP_INCLUDE
Method: $component -> config -> top_include
Since: 2.0b10
Gives you a piece of code that gets included at the very top of every file. Main character energy for real.
Example:
Embperl_Top_Include "use MY::Module;"
This will cause MY::Module to be used in every page. Note that Embperl_Top_Include must contain valid Perl code and must be ended with a semicolon. Don't forget the semicolon, bestie, she's important. โจ
NOTE: if you passtop_includeas a parameter toExecute, it's only used in the case that the code is compiled (or recompiled) and not cached.
๐ Embperl_Cache_Key ๐
Env: EMBPERL_CACHE_KEY
Method: $component -> config -> cache_key [read only]
Since: 2.0b1
A literal string that gets appended to the cache key. short and sweet. ๐
๐ Embperl_Cache_Key_Options ๐
Env: EMBPERL_CACHE_KEY_OPTIONS
Method: $component -> config -> cache_key_options [read only]
Default: all options set
Since: 2.0b1
Tells Embperl how to create a key for caching of the output. that's the whole thing, bestie. ๐
๐ Embperl_Expires_Func ๐
- Env:
EMBPERL_EXPIRES_FUNC - Method:
$component -> config -> expires_func[read only] - Since:
2.0b1
Bestie, this one is literally the bouncer at the door of your cache. ๐ This is the function that gets called every single time before data is taken out of the cache. And if this function returns true? The cached data isn't used anymore, it just gets rebuilt. Fresh. Brand new. Slay. โจ
The function can be any of these cuties:
- a coderef (when you pass it to
Execute), - a name of a subroutine, or
- a string starting with
"sub "โ in which case it gets compiled as an anonymous subroutine.
NOTE: If &EXPIRES is defined inside the page, it gets evaluated before the execution of the page. iykyk ๐
๐ฆ Embperl_Cache_Key_Func ๐ฆ
- Env:
EMBPERL_CACHE_KEY_FUNC - Method:
$component -> config -> cache_key_func - Since:
2.0b1
This is the function that should be called when you build a cache key. And the result? Appended to the cache key. That's it, that's the whole vibe. ๐
๐ธ Embperl_Expires_In ๐ธ
- Env:
EMBPERL_EXPIRES_IN - Method:
$component -> config -> expires_in[read only] - Since:
2.0b1
Time in seconds that the output should be cached, okay?
0= never-1= forever
Pick your fighter. ๐
NOTE: If $EXPIRES is set inside the page, it gets evaluated before the execution of the page. Not me reminding you twice, but likeโฆ I am. ๐ญ
๐ Embperl_Expires_Filename ๐
- Env:
EMBPERL_EXPIRES_FILENAME - Method:
$component -> config -> expires_filename[read only] - Since:
2.0b8
The cache should be expired when the given file is modified. Simple as that, bestie โ file changes, cache dips. ๐ซถ
โจ Embperl_Syntax โจ
- Env:
EMBPERL_SYNTAX - Method:
$component -> config -> syntax - Default:
Embperl - Since:
2.0b1
This is the one that tells Embperl which syntax to use inside a page. And Embperl comes with the following syntaxes, no cap:
EmbperlHTMLโ all the HTML tags that Embperl recognizes by defaultEmbperlBlocksโ all the[ ]blocks that Embperl supportsEmbperlโ (default; containsEmbperlHtmlandEmbperlBlocks)ASPโ<% %>and<%= %>, seeperldoc Embperl::Syntax::ASPSSIโ Server Side Includes, seeperldoc Embperl::Syntax::SSIPerlโ file contains pure Perl (similar toApache::Registry), but can be used insideEmbperlObjectTextโ file contains only Text, no actions are taken on the TextMailโ defines the<mail:send>tag, for sending mail. This is an example for a taglib, which could be a base for writing your own taglib to extent the number of available tagsPODโ translates pod files to XML, which can be converted to the desired output format by an XSLT transformationRTFโ can be used to process word processing documents in RTF format
You can get a description for each syntax if you type
perldoc Embperl::Syntax::xxx
where 'xxx' is the name of the syntax. So like, plug in the name, get the tea. โ
You can also specify multiple syntaxes, e.g.
EMBPERL_SYNTAX "Embperl SSI"
Execute ({inputfile => '*', syntax => 'Embperl ASP'}) ;
And the 'syntax' metacommand lets you switch the syntax, or add or subtract syntaxes, e.g.
[$ syntax + Mail $]
will add the Mail taglib so the <mail:send> tag is available after this line.
[$ syntax - Mail $]
now the <mail:send> tag is unknown again. Gone. Deleted. ๐
[$ syntax SSI $]
now you can only use SSI commands inside your page. That's the whole menu, bestie. ๐
๐ Embperl_Recipe ๐
- Env:
EMBPERL_RECIPE - Method:
$component -> config -> recipe[read only] - Since:
2.0b4
Tells Embperl which recipe to use to process this component. Cook with the right one. ๐ฉโ๐ณ
๐ง Embperl_Xsltstylesheet ๐ง
- Env:
EMBPERL_XSLTSTYLESHEET - Method:
$component -> config -> xsltstylesheet[read only] - Since:
2.0b5
Tell the xslt processor which stylsheet to use. (Yes, that's how it's spelled, don't come for me. ๐)
โญ Embperl_Xsltproc โญ
- Env:
EMBPERL_XSLTPROC - Method:
$component -> config -> xsltproc[read only] - Default: depends on compiltime options
- Since:
2.0b5
Tells Embperl which xslt processor to use. Currently "libxslt" and "xalan" are supported by Embperl, but they must be compiled in to be available. So like, if you didn't build it in, it's not showing up. Periodt. ๐ฅ
๐ธ Parameters ๐ธ
Okay bestie, so Parameters is where you get the tea โ on the current request or the current component doing its little thing. There's two flavors, and yes they're both iconic:
- Request parameters โ Embperl sets these up for you, automatically, from whatever's happening in the running environment. No effort required, she's self-sufficient ๐
- Component parameters โ these mostly just mirror whatever you handed to
Execute.
๐ filename
- Method:
$request -> param -> filename - Since:
2.0b6
Gives you the filename of the file that was actually requested. And here's the fun part: inside the application's init function you can change it to force Embperl to serve a whole different file. Sneaky. Love that for us. ๐
๐ unparsed_uri
- Method:
$request -> param -> unparsed_uri - Since:
2.0b6
The full unparsed_uri, and when I say full I mean it โ query_string and path_info are both in there too. The whole package deal. ๐
๐ uri
- Method:
$request -> param -> uri - Since:
2.0b6
The decoded path of the unparsed_uri. So like, the unparsed one but with its makeup off. โจ
๐ server_addr
- Method:
$request -> param -> server_addr - Since:
2.0b9
URL of the server handling the current request, formatted like schema://addr:port/ โ for example http://perl.apache.org/. And the port gets omitted if it's a default port, because she doesn't need to announce herself when she's being obvious. ๐โ๏ธ
๐ path_info
- Method:
$request -> param -> path_info - Since:
2.0b6
The path_info โ meaning anything in the path that comes after the file currently being served. The leftovers, the bonus content, the director's cut. ๐ฌ
๐ query_info
- Method:
$request -> param -> query_info - Since:
2.0b6
Any parameters passed in a GET request after the question mark. Now, the hash %fdat will contain these values already decoded and in a super easy-to-use way, so honestly it's normally more convenient to just use %fdat instead. Do with that what you will. ๐
๐ language
- Method:
$request -> param -> language - Since:
2.0b6
The primary language found in the browser's Accept-Language HTTP header. This value gets used for all the language-dependent functions inside Embperl. You can set it to change which message comes back from $request -> gettext and [= =]. Multilingual queen ๐
๐ cookies
- Method:
$request -> param -> cookies - Since:
2.0b6
A hashref containing all the cookies the browser sent to the server. All of them. Every last crumb. ๐ช
๐ cgi
- Method:
$request -> param -> cgi [read only] - Since:
2.0b12
Holds the CGI.pm object, which is what's used for file upload. But heads up: if no file-uploaded data was sent to the request, this member is undefined. So vibe check it before you go touching it. ๐ซถ
๐ inputfile
- Method:
$component -> param -> inputfile [read only] - Since:
1.0.0
Gives the name of the file that should be processed, like:
Execute({inputfile => 'mysource.epl'}) ;
And because we're nice, there's a shortcut for when you only need to give the input file and no other parameters. The above does the same thing as:
Execute('mysource.epl') ;
Same energy, fewer characters. Slay. ๐
๐ outputfile
- Method:
$component -> param -> outputfile [read only] - Default:
STDOUT - Since:
1.0.0
Specify a file to which the output should be written. Example:
Execute({inputfile => 'mysource.epl',
outputfile => 'myoutput.htm'}) ;
๐ input
- Method:
$component -> param -> input [read only] - Since:
1.0.0
Use this parameter when you already have the source sitting in memory. You should pass a reference to a scalar that contains the source. And additionally you should give the inputfile parameter, so Embperl's caching can keep track of all your different in-memory sources (yes bestie, it needs the receipts ๐งพ).
The mtime parameter is what tells Embperl's cache whether the source has changed since the last call or not. If mtime is undef, or if it's a different value than it was during the last call, the source is considered changed and everything gets recompiled. Example:
# Get source from scalar
# Don't forget to modify mtime if $src changes
$src = '<html><head><title>Page [+ $no +]</title></head>' ;
Embperl::Execute ({ inputfile => 'some name',
input => \$src,
mtime => 1 }) ;
๐ output
- Method:
$component -> param -> output [read only] - Since:
1.0.0
Gives you the option to write the output into a scalar instead of sending it off to stdout or a file. You should give a reference to a scalar. Example:
Execute({inputfile => 'mysource.epl',
output => \$out}) ;
๐ sub
- Method:
$component -> param -> sub [read only] - Since:
1.2.0
Calls the given Embperl subroutine that's defined with [$sub$] inside the page. And there's a shortcut: just append the name of the subroutine after the filename with a hash sign, because we love efficiency. So these two calls are doing the exact same thing:
Execute('mysource.epl#mysub') ;
Execute({inputfile => 'mysource.epl',
sub => 'mysub'}) ;
And if you leave out the filename entirely, the sub gets called in the current file โ which means this can only be used inside a file that's already being processed by Embperl. No time travel allowed. โณ
๐ subreq
- Method:
$component -> param -> subreq - Since:
2.0b8, Apache 2.x
This one utilizes Apache 2.0 filters to grab the output of a sub-request and use it as the input for the current component. So say you've got a CGI-Script and you need to post-process it through Embperl, or you simply want to include its output inside another Embperl/Embperl::Object document โ you can write:
[- Execute ({subreq => '/cgi-bin/script.cgi'}) -]
โ ๏ธ NOTE: You have to specify a URI and not a filename! Do not mess this up, bestie, I'm begging. ๐ญ
๐ import
- Method:
$component -> param -> import [read only] - Since:
1.3.0
A value of one tells Embperl to define the subroutines inside the file (if that hasn't already been done) and import them as perl subroutines into the current namespace.
See the [$ sub $] metacommand and the section about subroutines for more info. ๐
A value of zero tells Embperl to simply precompile all the code found in the page. And note โ with 2.0 it's not necessary anymore to do that before using the sub parameter on a different file. Glow up. โจ
๐ firstline
- Method:
$component -> param -> firstline [read only] - Default:
1 - Since:
1.2.0
Specifies the first linenumber of the sourcefile. Counting starts where you say it starts. ๐ฏ
๐ mtime
- Method:
$component -> param -> mtime [read only] - Default:
undef - Since:
1.0.0
Last modification time of parameter input. If it's undef, the code passed by input is always recompiled. Otherwise the code only gets recompiled if mtime changes. Simple as. ๐ฐ๏ธ
๐ param
- Method:
$component -> param -> param [read only] - Since:
1.0.0
Can be used to pass parameters to the Embperl document and back. Must contain a reference to an array. Example:
Execute({inputfile => 'mysource.epl',
param => [1, 2, 3]}) ;
Execute({inputfile => 'mysource.epl',
param => \@parameters}) ;
And there's a shortcut, so the following code is the equivalent (NOTE: don't use an array ref here, okay?):
Execute('mysource.epl', 1, 2, 3) ;
Execute('mysource.epl', @parameters) ;
The array @param in the Embperl document gets set up as an alias to that array. See eg/x/Excute.pl for a more detailed example. ๐
๐ fdat
- Method:
$component -> param -> fdat [read only] - Since:
1.0.0
Pass a hash reference to customly set %fdat. And if ffld isn't given, ffld will be set to keys %fdat. Teamwork makes the dream work. ๐ซฑ๐ซฒ
๐ ffld
- Method:
$component -> param -> ffld [read only] - Since:
1.0.0
Pass an array reference to customly set @fdat. Does not affect %fdat. They're separate girls, keep them separate. ๐ซ
๐ object
- Method:
$component -> param -> object [read only] - Since:
1.3.2
Takes a filename and returns a hashref that is blessed into the package of the given file. Super useful if you want to call the subs inside that given file as methods. And by using the isa parameter (see below, keep reading bestie) you're able to provide an inherence tree. Bonus: you can also use the returned hashref to store data for that object. Example:
[# the file eposubs.htm defines two subs: txt1 and txt2 #]
[# first we create a new object #]
[- $subs = Execute ({'object' => 'eposubs.htm'}) -]
[# then we call methods inside the object #]
txt1: [+ $subs -> txt1 +] <br>
txt2: [+ $subs -> txt2 +] <br>
๐ isa
- Method:
$component -> param -> isa [read only] - Since:
1.3.2
Takes a name of a file and pushes the package of that file into the @ISA array of the current file. By using this you can set up an inherence tree between Embperl documents. It's also useful within Embperl::Object. Example:
[! Execute ({'isa' => '../eposubs.htm'}) !]
Family tree but make it code. ๐ณ
๐ errors
- Method:
$component -> param -> errors [read only] - Since:
1.3.0
Takes a reference to an array. Upon return, that array will contain a copy of all the errormessages, if there are any. (Fingers crossed there aren't. ๐ค)
๐ xsltparam
- Method:
$component -> param -> xsltparam - Default:
%fdat - Since:
2.0b6
Takes a reference to a hash which contains key/value pairs that are accessible inside the stylesheet via <xsl:param>. Very demure, very XSLT. ๐
๐ Embperl's Objects ๐
Okay so there are three major objects in Embperl, and they're basically the main characters:
- application
- request
- component
Each one of these can be used to get info about the processing and to control the execution. And each one has a config sub-object, which makes the configuration accessible and โ where possible โ changeable at runtime. The config method of these three objects returns a reference to the configuration object. All the methods of those configuration objects are described up in the Configuration section. ๐
The request and component objects additionally have a parameter sub-object, which holds the parameters passed to the current request/component. The param method of these two objects returns the parameter sub-object, and all its methods live in the Parameters section (hi, that's the one you just read ๐).
And on top of all that, each of the three major objects has a set of its own methods, which we're about to get into right now. Let's go. ๐ฅ
๐ฆ thread
- Method:
$application -> thread [read only] - Since:
2.0b6
Returns a reference to an object which holds per-thread information. There is only one such object per thread โ she's exclusive, she's not sharing. ๐
๐ฆ curr_req
- Method:
$application -> curr_req [read only] - Since:
2.0b6
Returns a reference to the current request object, i.e. the object of the request that's currently running. The one on stage right now. ๐ค
๐ฆ config
- Method:
$application -> config [read only] - Since:
2.0b6
Returns a reference to the configuration object of the application. See the Configuration section for all the deets. โจ
๐ฆ user_session
- Method:
$application -> user_session [read only] - Since:
2.0b6
Returns a reference to the user session object. Your session, your rules. ๐ซถ
๐ซถ state_session
Method:
$application -> state_session [read only]
Since: 2.0b6
Hands you back a reference to the state session object. That's it, that's the whole vibe. โจ
๐ซถ app_session
Method:
$application -> app_session [read only]
Since: 2.0b6
Returns a reference to the application session object. The app-wide one, bestie, not the personal one. ๐
๐ udat
Method:
$application -> udat [read only]
Since: 2.0b6
Returns a reference to a hash holding the user session data. You can read it and poke at it to modify that data, no cap. It's literally the same thing as reaching for the global %udat. ๐ฅ
๐ sdat
Method:
$application -> sdat [read only]
Since: 2.0b6
Returns a reference to a hash holding the state session data. Read it, change it, live your truth. Exactly the same as touching the global %sdat. โจ
๐ mdat
Method:
$application -> mdat [read only]
Since: 2.0b6
Returns a reference to a hash holding the application session data. Use it to access and modify that data. Same deal as the global %mdat. ๐
๐ errors_count
Method:
$application -> errors_count
Since: 2.0b6
Holds the number of errors since the last time they got sent per mail. See also mail_errors_to. Not me tracking my L's ๐
โฐ errors_last_time
Method:
$application -> errors_last_time
Since: 2.0b6
The time when the last error occurred. See also mail_errors_to.
๐ฌ errors_last_send_time
Method:
$application -> errors_last_send_time
Since: 2.0b6
The time when the last mail with error messages was sent. See also mail_errors_to.
๐ the request object's little methods
okay bestie, new object, same energy โ this is all the stuff hanging off the request object. ๐ง
๐ apache_req
Method:
$request -> apache_req [read only]
Since: 2.0b6
Returns a reference to mod_perl's Apache request object. In mod_perl 1 it's of type "Apache::", and in mod_perl 2 it's a "Apache2::RequestRec". Pick your era, both are iconic. ๐
โ๏ธ config
Method:
$request -> config [read only]
Since: 2.0b6
Returns a reference to the configuration object of the request. Go peep the Configuration section for the deets.
๐ param
Method:
$request -> param [read only]
Since: 2.0b6
Returns a reference to the parameter object of the request. Parameters section, iykyk.
๐งฉ component
Method:
$request -> component [read only]
Since: 2.0b6
Returns a reference to the object of the component that's currently running. See the component methods below. โญ
๐ธ app
Method:
$request -> app [read only]
Since: 2.0b6
Returns a reference to the object of the application that the current request belongs to. Application methods are above, go look. ๐
๐งต thread
Method:
$request -> thread [read only]
Since: 2.0b6
Returns a reference to an object holding per-thread information. There's exactly one of these objects per thread. One. Singular. The main character of its thread. ๐
๐ข request_count
Method:
$request -> request_count [read only]
Since: 2.0b6
Returns the number of requests this child process has handled so far. Keeping receipts fr fr.
โฑ๏ธ request_time
Method:
$request -> request_time [read only]
Since: 2.0b6
The start time of the current request.
๐ session_mgnt
Method:
$request -> session_mgnt [read only]
Since: 2.0b6
Set to true if session management is available. Slay.
๐ session_id
Method:
$request -> session_id [read only]
Since: 2.0b6
The combined id of the current user and state session. Two sessions, one id, iconic duo energy. ๐
๐ session_state_id
Method:
$request -> session_state_id [read only]
Since: 2.0b6
The id of the current state session as received by the browser. Which means for a brand new session this method returns "undef" โ she's new here, no id yet. ๐
๐ session_user_id
Method:
$request -> session_user_id [read only]
Since: 2.0b6
The id of the current user session as received by the browser. Same deal: for a new session this returns "undef". ๐ฆ
๐ช cookie_expires
Method:
$request -> cookie_expires
Since: 2.1.1
Use this to retrieve the actual expiration date that Embperl uses for the cookie holding the session id. Yes, cookies. Delicious. ๐ชโจ
๐ช had_exit
Method:
$request -> had_exit [read only]
Since: 2.0b6
True if exit was called in one of the components processed so far. She left the building. ๐
๐ log_file_start_pos
Method:
$request -> log_file_start_pos [read only]
Since: 2.0b6
The file position of the log file at the moment the request started. Bookmarking where we came in. ๐
๐ญ error
Method:
$request -> error
Since: 2.0b6
True if there were any errors during the request. A vibe check that came back negative.
๐ errors
Method:
$request -> errors
Since: 2.0b6
A reference to an array holding all error messages that have occurred so far. The whole receipts folder.
๐๏ธ errdat1
Method:
$request -> errdat1
Since: 2.0b6
Additional information passed to the error handler when an error is reported.
๐๏ธ errdat2
Method:
$request -> errdat2
Since: 2.0b6
More additional information passed to the error handler when an error is reported. Yes there are two. One for each pocket. ๐
โ ๏ธ lastwarn
Method:
$request -> lastwarn
Since: 2.0b6
The last warning message.
๐ช errobj
Method:
$request -> errobj
Since: 2.0rc3
The object passed to the last die, if there was one. Super handy when you pass an object to die inside an Execute: afterwards you can check $epreq -> errobj to grab that object back. The object also gets pushed onto the array you passed to the errors parameter of Execute. Look at her, being useful. ๐
๐งน cleanup_vars
Method:
$request -> cleanup_vars
Since: 2.0b6
A reference to an array filled with references to variables that need cleaning up after the request. You can add your own variables that need cleanup here.
๐จ bestie listen: you should never remove any variables from this array. Ever. Do not touch the removals. ๐ โโ๏ธ
๐งผ cleanup_packages
Method:
$request -> cleanup_packages
Since: 2.0b6
A reference to a hash containing all the packages that must be cleaned up after the request. Spring cleaning but make it Perl. โจ
๐ initial_cwd
Method:
$request -> initial_cwd [read only]
Since: 2.0b6
The working directory when the request started. Where we were when this whole thing began. ๐ธ
๐ messages
Method:
$request -> messages
Since: 2.0b6
A reference to an array of hashes of messages. Embperl uses this to translate messages into different languages. When a [= =] block is processed, or when $request -> gettext is called, Embperl searches this array. It starts at the first element (and every element in the array has to be a hashref) and tries to look up the text for the given symbol in that hash. If it fails, it moves on to the next array element. That way you can set up multiple translation tables that all get searched for the symbol. ๐
Example:
%messages =
(
'de' =>
{
'addsel1' => 'Klicken Sie auf die Kategorie zu der Sie etwas hinzufรผgen mรถchten:',
'addsel2' => 'oder fรผgen Sie eine neue Kategorie hinzu. Bitte geben Sie die Beschreibung in so vielen Sprachen wie Ihnen mรถglich ein.',
'addsel3' => 'Falls Sie die รbersetzung nicht wissen, lassen Sie das entsprechende Eingabefeld leer.',
'addsel4' => 'Kategorie hinzufรผgen',
},
'en' =>
{
'addsel1' => 'Click on the category for which you want to add a new item:',
'addsel2' => 'or add new category. Please enter the description in as much languages as possible.',
'addsel3' => 'If you don\'t know the translation leave the corresponding input field empty.',
'addsel4' => 'Add category',
}
) ;
$lang = $request -> param -> language ;
push @{$request -> messages}, $messages{$lang} ;
push @{$request -> default_messages}, $messages{'en'} if ($lang ne 'en') ;
"$request -" param -> language> grabs the language as given by the browser's language-accept header (or as set earlier in your program). Then it pushes the German or English messages hash onto the message array. On top of that, it pushes the English messages onto the default_messages array. Messages get taken from that array whenever nothing can be found in the messages array. Backups, bestie. Always have backups. ๐ซถ
๐๏ธ default_messages
Method:
$request -> default_messages
Since: 2.0b6
A reference to an array of default messages. Messages get pulled from this array whenever nothing can be found in the messages array. The fallback bestie who always shows up. ๐
๐งฉ the component object's methods
new object, who dis โ everything below hangs off the component object. ๐
โ๏ธ config
Method:
$component -> config [read only]
Since: 2.0b6
Returns a reference to the configuration object of the component.
๐ param
Method:
$component -> param [read only]
Since: 2.0b6
Returns a reference to the parameter object of the component.
๐โโ๏ธ req_running
Method:
$component -> req_running [read only]
Since: 2.0b6
True if Embperl is currently inside the execution of the request. She's running, don't interrupt. ๐ฅ
๐ช sub_req
Method:
$component -> sub_req [read only]
Since: 2.0b6
True if this is not the outermost Embperl component โ i.e. this component got called from inside another component. A component within a component. ๐ช
๐ซง inside_sub
Method:
$component -> inside_sub [read only]
Since: 2.0b6
True if we're inside an Embperl subroutine ([$ sub $] ... [$ endsub $]). Deep in the sub, bestie. ๐
๐ช had_exit
Method:
$component -> had_exit [read only]
Since: 2.0b6
True if exit was called during the execution of the component. She said bye. ๐ญ
๐ค๏ธ path_ndx
Method:
$component -> path_ndx [read only]
Since: 2.0b6
Tells Embperl how much of the path should be ignored when searching through the path. Skipping ahead, iconic. โญ
๐ cwd
Method:
$component -> cwd [read only]
Since: 2.0b6
The directory of the source file of the component.
๐ sourcefile
Method:
$component -> sourcefile [read only]
Since: 2.0b6
The source file of the component. Where she came from. ๐ฆ
๐จ syntax
Method:
$component -> syntax
Since: 2.0b6
The syntax of the component.
โฌ
๏ธ prev
Method:
$component -> prev [read only]
Since: 2.0b6
The previous component โ like, the component that called this one. Her origin story. ๐
๐ฆ import_stash
Method:
$component -> import_stash [read only]
Since: 2.0b6
While importing a component, this is set to the stash to which symbols are imported. During normal execution it's "undef". So if you see "undef", nothing's being imported right now, chill. โจ
๐ค exports
Method:
$component -> exports
Since: 2.0b6
The symbols that should be exported by this component. Sharing is caring. ๐ซถ
๐ท๏ธ curr_package
Method:
$component -> curr_package [read only]
Since: 2.0b6
The name of the package the component is executed in. Know her name, know her game. ๐
๐ฆ code ๐ฆ
- Method:
$component -> code - Since:
2.0b6
Okay bestie, listen โ this one is only valid during the compile phase. Like, it does not exist outside of that window, so don't go calling it at runtime and then act surprised, because the vibe check will fail. ๐
What it does though? It's lowkey iconic. You can use it to retrieve and modify the code that Embperl is generating. Yes, the actual generated code. The way that it just hands you the source being built... main character energy fr fr. ๐
If you wanna go deeper, hit up Embperl::Syntax for all the details, and if you're the kind of person who learns by example (me too, always), Embperl::Syntax::RTF is right there serving as a whole example. ๐ซถ
And that's a wrap, bestie!! ๐ This whole little manual page was brought to you by perl v5.34.0, dated 2022-02-06, and it lives under the name Config(3pm). โจ Go forth and configure responsibly, mwah ๐๐๐ธ
๐ฆ where this page comes from
- ubuntu jammy: libembperl-perl 2.5.0-16build1 ยท Artistic-1.0-Perl OR GPL-1.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms