You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Scott Chapman <sc...@mischko.com> on 2002/06/12 23:33:43 UTC

How to get at constant.epl from outside the web evironment?

I have a constant.epl file that defines some variables as part of $req:

[-
    $req = shift;
    $req->{website_database} = 'DBI:Sprite:/www/db/Annual_Review';
    $req->{website_event_table} = 'ar_events';
    $req->{website_sequence} = 'ar_num';
    $req->{db_user} = 'username';
    $req->{db_pass} = 'password';
-]

I need to get at those definitions in a perl script outside the www 
environment and I'm not sure how to do it.  Is there a easy way to do this?

Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: How to get at constant.epl from outside the web evironment?

Posted by Axel Beckert - ecos gmbh <be...@ecos.de>.
Hi!

On Wed, Jun 12, 2002 at 10:55:59PM -0700, Wim Kerkhoff wrote:
> My first suggestion would be to look at HTML::Embperl::Execute, and
> see if you can send it a reference to your own request object.
> 
> I agree with idea that someone else had though... move the configuration 
> into it's own module that both embperl pages and perl scripts can
> load. 

IMHO that's a much easier and better solution.

> Or, just store it in a text file that the config routine can load.

For this solution I suggest AppConfig.pm. Consult your favourite CPAN
mirror for downloading it. ;-)

            Kind regards, Axel Beckert
-- 
-------------------------------------------------------------
Axel Beckert      ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

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

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: How to get at constant.epl from outside the web evironment?

Posted by Wim Kerkhoff <wi...@nyetwork.org>.
Scott Chapman wrote:
> I have a constant.epl file that defines some variables as part of $req:
> 
> [-
>     $req = shift;
>     $req->{website_database} = 'DBI:Sprite:/www/db/Annual_Review';
>     $req->{website_event_table} = 'ar_events';
>     $req->{website_sequence} = 'ar_num';
>     $req->{db_user} = 'username';
>     $req->{db_pass} = 'password';
> -]
> 
> I need to get at those definitions in a perl script outside the www 
> environment and I'm not sure how to do it.  Is there a easy way to do this?

My first suggestion would be to look at HTML::Embperl::Execute, and see 
if you can send it a reference to your own request object.

I agree with idea that someone else had though... move the configuration 
into it's own module that both embperl pages and perl scripts can load. 
Or, just store it in a text file that the config routine can load.

Wim



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: How to get at constant.epl from outside the web evironment?

Posted by Cameron McBride <ca...@cwru.edu>.
On Wed, Jun 12, 2002 at 02:33:43PM -0700, Scott Chapman wrote:
> I have a constant.epl file that defines some variables as part of $req:
> 
> [-
>     $req = shift;
>     $req->{website_database} = 'DBI:Sprite:/www/db/Annual_Review';
>     $req->{website_event_table} = 'ar_events';
>     $req->{website_sequence} = 'ar_num';
>     $req->{db_user} = 'username';
>     $req->{db_pass} = 'password';
> -]
> 
> I need to get at those definitions in a perl script outside the www 
> environment and I'm not sure how to do it.  Is there a easy way to do this?

Completely outside the www environment?  You mean under a different
perl process?  

The only thing that knows what these variables are, is the perl
interpreter running under your web environment (be it CGI or mod_perl).
mod_perl might be able to communicate between scripts via globals, but
they have to both be under the www environment.  A child process could
get the information via environment variables, if Embperl exported them,
but again -- this only works for a child process.

There needs to be some method of communication between the processes.  
If you don't want Embperl to do anything different, you might have your 
perl script parse the 'constant.epl' file.  (what I mean by different,
is for embperl to establish some method of IPC -- one of the simplest of
which are files.)  

As for a direct means to access these variables in memory (assuming they
are different perl interpreters) -- I am pretty sure thats not a 
possibility, at least not for a reasonably sane solution.   

Does this answer your question?  

Cameron

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: How to get at constant.epl from outside the web evironment?

Posted by Gavin Carr <ga...@openfusion.com.au>.
On Wed, Jun 12, 2002 at 02:33:43PM -0700, Scott Chapman wrote:
> I have a constant.epl file that defines some variables as part of $req:
> 
> [-
>     $req = shift;
>     $req->{website_database} = 'DBI:Sprite:/www/db/Annual_Review';
>     $req->{website_event_table} = 'ar_events';
>     $req->{website_sequence} = 'ar_num';
>     $req->{db_user} = 'username';
>     $req->{db_pass} = 'password';
> -]
> 
> I need to get at those definitions in a perl script outside the www 
> environment and I'm not sure how to do it.  Is there a easy way to do this?

As usual, TMTOWTDI. The quick way is to eval it like Tiago suggested.

If you need to do this in multiple scripts it might be cleaner to create
a module you can just 'use' e.g.

  package Config;

  our %const = (
      website_database => 'DBI:Sprite:/www/db/Annual_Review',
      website_event_table => 'ar_events',
      website_sequence => 'ar_num',
      db_user => 'username',
      db_pass => 'password',
  );

  1;

and then in your constant.epl do:

  [! use Config; !]
  [- 
      $req = shift;
      @$req{ keys %Config::const } = values %Config::const;
  -]

Cheers,
Gavin

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: How to get at constant.epl from outside the web evironment?

Posted by Angus Lees <gu...@switchonline.com.au>.
At Wed, 12 Jun 2002 14:33:43 -0700, Scott Chapman wrote:
> I have a constant.epl file that defines some variables as part of $req:
> 
[...]
> 
> I need to get at those definitions in a perl script outside the www 
> environment and I'm not sure how to do it.  Is there a easy way to do this?

the "nice" way of doing it is to pass $req as an argument to the
relevant perl code.

in embperl 1.3, you can do "$req = HTML::Embperl::CurrReq();"
but i'm guessing (hoping ;) that doesn't work in 2.0

-- 
 - Gus

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org