Mailing List Archive

HTML::Embperl::Execute question re embedded commands
This is probably a really dumb question. I just recently began using
Embperl and cannot find an easy way to do the following:

I would like ot embed Embperl commands e.g. [+ $blah +] inside text which
has been retrieved from a database via DBI or DBIx.

The only way I can seem to get the commands to be seen by Embperl is to
write the text to a file and then Execute it. This is because the Execute
command seems to demand a filename. This seems inefficient and slow, not to
mention inelegant.

I would like to just give the text string to Embperl somehow and have it
"eval" the string, processing it like other code with Embperl commands.

Ideally, it would not be necessary to have the text be executed in its own
scope, but rather in the same scope as the file it is included in. To
clarify: If I declare a variable $foo in a file, then get some text from a
database in that same file, I would like to be able to refer to $foo in
that retrieved text and have it be evaluated in that same context.

Apologies if this is a really stupid question...

FWIW I really like Embperl and am using it for some quite large projects.
It's the foundation for two or three websites which I am developing.

Thanks for any suggestions

-Neil Gunton
RE: HTML::Embperl::Execute question re embedded commands [ In reply to ]
>
> I would like ot embed Embperl commands e.g. [+ $blah +] inside text which
> has been retrieved from a database via DBI or DBIx.
>

The source for Execute can come from a scalar. The docs contains examples
(http://perl.apache.org/embperl/Embperl.pod.1.html#EXAMPLES_for_Execute_)
If you like that the code is executed in the same package, then you have to
add the package parameter:

HTML::Embperl::Execute ({ input => \$src,
package => __PACKAGE__ }) ;

This will compile the perl code in $src for every call, with the parameter
inputfile and mtime you can tell Embperl how to cache precompiled code and
when it changes (as far as you know when the source in the db has changed)

Gerald




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

Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------