> I'm looking at possibly using EmbPerl.  However, the way I want to use it
> is kind of different from what you describe in your readme files.
>
> Basically, I want Embperl to act as just a module, not as an Apache plugin
> or anything that would be closely tied in to Apache or the machine it is
> running on.
>
> I want to be able to write my cgi scripts as programs themselves to gather
> all of the data that I want displayed on a page.  Then I want to reference
> an html template file where all of this data can be used.  It looks like I
> can do something like this with your Execute call.

Yes, of course you can

>  In my main program,
> can I populate a hash with all of the data I want, say, %data, and then do
> this:
>
> $data{foo} = 4;
>
> HTML::Template::Execute('main.tmpl', %data)
>
> Then in the html file, can I do this:
>
> [+ $data{foo} +]
>
> Will that then be replaced with 4?  If I'm a little off on the operation,
> tell me how to accomplish something like this.  I used HTML::Template for
> a while, but that is definitely restricting in a few respects.  On the
> flip side, a module like yours might be too complex for what I want to do.
>

With a few changes the above code works. The parameter you pass to Execute
are passed to the page with the @params array (similar to the @_ array that
Perl uses for parameter passing to subroutines). So your code has to look
like this:


$data{foo} = 4;

HTML::Embperl::Execute('main.tmpl', %data)

 Then in the html file, can you do this:
[- %data = @param -]

[+ $data{foo} +]


Or you could pass the hash by reference, which is faster for bigger hashs.
The difference is that any change to that hash inside the page also changes
the hash in your cgi script. This would look like this:

$data{foo} = 4;

HTML::Embperl::Execute('main.tmpl', \%data)

 Then in the html file, can you do this:
[- $data = $param[0] -]

[+ $data -> {foo} +]

Or pass it as named parameters:


HTML::Embperl::Execute('main.tmpl', 4, 888)

 Then in the html file, can you do this:
[- ($foo, $bar) = @param -]

[+ $foo +] [+ $bar +]

will display 4 and 888

Hope this helps

Gerald

P.S. Please send further questions to the Embperl mailing list

------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     [EMAIL PROTECTED]         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to