perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gerald Richter - ECOS <gerald.rich...@ecos.de>
Subject FW: How does [! sub() !] work ?
Date Thu, 06 May 2010 14:45:08 GMT


-----Original Message-----
From: Ed Grimm [mailto:ed_grimm@raytheon.com] 
Sent: Thursday, May 06, 2010 1:50 PM
To: Jean-Christophe Boggio; embperl@perl.apache.org
Subject: Re: How does [! sub() !] work ?

While Gerald's suggestion is the best one for your specific example, there could be other
issues you're having that could benefit from further enlightenment.

[! !] blocks do not declare a lexical scope.  You're running into at least two issues:

1. At the end of page processing, all the private namespace variables are cleaned up, so $req
isn't even around for routines in subs.epl after the initial load.  As such, I find it convinent
to put all of my global constants in their own namespace.  One can disable this cleanup, but
that opens you up to data bleeds and semi-controlled memory bloat.

2. These blocks are only processed on the initial load, so $req would be invalid on the subsequent
requests anyway.

Ed


----- Original Message -----
From: Jean-Christophe Boggio [embperl@thefreecat.org]
Sent: 05/06/2010 03:41 AM ZE2
To: "embperl@perl.apache.org" <embperl@perl.apache.org>
Subject: How does [! sub() !] work ?



Hello,

I want to define a few subs used everywhere on my site. So I wrote :

lib/subs.epl:

[!
$req = shift;

sub test {
	print OUT "test";
}
!]

test.html:
[-
$subs = Execute({object => "$ENV{DOCUMENT_ROOT}/lib/subs.epl"});
$subs->test;
-]


This works fine but I can't get the values in $req from subs.epl and
I need my $req->{dbh}...

Any clue ? Thanks for your help,

-- 
Jean-Christophe Boggio                       -o)
embperl@thefreecat.org                       /\\
Independant Consultant and Developer        _\_V

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




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


Mime
View raw message