Embperl - building dynamic websites with Perl


Parameters
[ << Prev: Configuration ] [ Content ] [ Next: Embperl's Objects >> ]

Parameters gives addtionaly information about the current request or the execution of the current component. So we have two sorts of parameters Request and Component parameters. Request parameters are automatically setup by Embperl with information Embperl takes from the current running environment. When Embperl is invoked via the Execute function, you can pass any of the parameters to Execute. Component parameters mainly reflect the parameters given to Execute.



filenametop
 

Method:

 

$request -> param -> filename

 

Since:

 

2.0b6

Gives the filename of the file that was actualy requested. Inside of the applications init function it can be changed to force Embperl to serve a different file.



unparsed_uritop
 

Method:

 

$request -> param -> unparsed_uri

 

Since:

 

2.0b6

The full unparsed_uri, includeing the query_string and the path_info.



uritop
 

Method:

 

$request -> param -> uri

 

Since:

 

2.0b6

The decoded path of the unparsed_uri.



server_addrtop
 

Method:

 

$request -> param -> server_addr

 

Since:

 

2.0b9

URL of the server of the current request in the form schema://addr:port/ e.g. https://perl.apache.org/ (port is omitted if it is an default port)



path_infotop
 

Method:

 

$request -> param -> path_info

 

Since:

 

2.0b6

The path_info, that is anything in the path after the file the is currently served.



query_infotop
 

Method:

 

$request -> param -> query_info

 

Since:

 

2.0b6

Any parameters passed in a GET request after the question mark. The hash %fdat will contain these values in a already decoded and easy to use way. So it's normly more convenient to use %fdat instead.



languagetop
 

Method:

 

$request -> param -> language

 

Since:

 

2.0b6

The primary langange found in the browser Accept-Language HTTP header. This value is used for all language-dependent functions inside Embperl. You can set it change the selection of message returned by $request -&gt; gettext and [= =].



cookiestop
 

Method:

 

$request -> param -> cookies

 

Since:

 

2.0b6

A hashref that contains all cookies send by the browser to the server.



cgitop
 

Method:

 

$request -> param -> cgi [read only]

 

Since:

 

2.0b12

Holds the CGI.pm object, which is used for file upload. If no file uploaded data is send to the request, this member is undefined.



inputfiletop
 

Method:

 

$component -> param -> inputfile [read only]

 

Since:

 

1.0.0

Give the name of the file that should be processed, e.g.

    Execute({inputfile => 'mysource.epl'}) ;

There is a shortcut when you only need to give the input file and no other parameters. The above is will do the same as:

    Execute('mysource.epl') ;


outputfiletop
 

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'}) ;


inputtop
 

Method:

 

$component -> param -> input [read only]

 

Since:

 

1.0.0

This parameter is used, when you have the source already in memory. You should pass a reference to a scalar that contains the source. Addtionaly you should give the inputfile parameter, to allow Embperl caching to keep track of different in memory sources. The mtime parameter is used to tell Embperl's cache if the source has change since the last call or not. If mtime if undef or of a different value as it was during the last call, the source is considered to be changed and everything is 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 }) ;
  


outputtop
 

Method:

 

$component -> param -> output [read only]

 

Since:

 

1.0.0

Gives the possibility to write the output into a scalar instead of sending it to stdout or a file. You should give a reference to a scalar. Example:

    Execute({inputfile  => 'mysource.epl',
             output     => \$out}) ;


subtop
 

Method:

 

$component -> param -> sub [read only]

 

Since:

 

1.2.0

Call the given Embperl subroutine defined with [$sub$] inside the page. A shortcut for this is to append the name of the subroutine after the filename with a hash sign, so the following calls are doing the same thing:

    Execute('mysource.epl#mysub') ;

    Execute({inputfile  => 'mysource.epl',
             sub        => 'mysub'}) ;

If you leave out the filename, the sub is called in the current file, so this can only be used inside a file that is already processed by Embperl.



subreqtop
 

Method:

 

$component -> param -> subreq

 

Since:

 

2.0b8, Apache 2.x

This utilizies Apache 2.0 filters to retrieve the output of a sub-request and uses it as input for the current component. For example if you have a CGI-Script and you need to post process it via Embperl or simply want to include it's output in 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!



importtop
 

Method:

 

$component -> param -> import [read only]

 

Since:

 

1.3.0

A value of one tells Embperl to define the subrountines inside the file (if not already done) and to import them as perl subroutines into the current namespace.

See [$ sub $] metacommand and section about subroutines for more info.

A value of zero tells Embperl to simply precompile all code found in the page. (With 2.0 it is not necessary anymore to do it before using the sub parameter on a different file).



firstlinetop
 

Method:

 

$component -> param -> firstline [read only]

 

Default:

 

1

 

Since:

 

1.2.0

Specifies the first linenumber of the sourcefile.



mtimetop
 

Method:

 

$component -> param -> mtime [read only]

 

Default:

 

undef

 

Since:

 

1.0.0

Last modification time of parameter input. If undef the code passed by input is always recompiled, else the code is only recompiled if mtime changes.



paramtop
 

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}) ;

There is a shortcut, so the following code the aquivalent (NOTE: Don't use a array ref here):

    Execute('mysource.epl', 1, 2, 3) ;
    Execute('mysource.epl', @parameters) ;

The array @param in the Embperl document is setup as an alias to the array. See eg/x/Excute.pl for a more detailed example.



fdattop
 

Method:

 

$component -> param -> fdat [read only]

 

Since:

 

1.0.0

Pass a hash reference to customly set %fdat. If ffld is not given, ffld will be set to keys %fdat.



ffldtop
 

Method:

 

$component -> param -> ffld [read only]

 

Since:

 

1.0.0

Pass a array reference to customly set @fdat. Does not affect %fdat.



objecttop
 

Method:

 

$component -> param -> object [read only]

 

Since:

 

1.3.2

Takes a filename and returns an hashref that is blessed into the package of the given file. That's useful, if you want to call the subs inside the given file, as methods. By using the isa parameter (see below) you are able to provide an inherence tree. Additionally you can 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>


isatop
 

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 setup an inherence tree between Embperl documents. Is is also useful within Embperl::Object. Example:

    [! Execute ({'isa' => '../eposubs.htm'}) !]


errorstop
 

Method:

 

$component -> param -> errors [read only]

 

Since:

 

1.3.0

Takes a reference to an array. Upon return, the array will contain a copy of all errormessages, if any.



xsltparamtop
 

Method:

 

$component -> param -> xsltparam

 

Default:

 

%fdat

 

Since:

 

2.0b6

Takes a reference to hash which contains key/value pair that are accessible inside the stylesheet via <xsl:param>.


[ << Prev: Configuration ] [ Content ] [ Next: Embperl's Objects >> ]


© 1997-2023 Gerald Richter / actevy