Hi, > > While working to port some code to Embperl 2.0 I discovered > some odd behavior with regards to subroutines and passing the > $req object. I'm sure that I'm just doing it wrong, but code > that worked in 1.3 will not work in 2.0. I didn't see any > mention of changes in regards to how Embperl 2 handles > subroutines and the $req object, but I could have missed it.
The scoping has change in 2.0. What you done in 1.3 worked, but it was never itended to work. > > subs.epl > ---------- > [! > $req = shift; > !] The above is done when the file is first loaded > [$ sub ccHelloWorld $] > <p>Sub: [+ $req->{TEST} +]</p> > [$ endsub $] > $req isn't defined anymore when the sub is called (because it's now a different request, then when the [! !] was executed; at least for the second and so on request) > > I've tried this a few different ways, including passing $req > directly to the sub: > This is a good idea, but this is a method call, so you get the object as first parameter and the $req as second, so the follwing will work: > > subs.epl > --------- > [$ sub ccHelloWorld $] [- ($self, $req) = @_ -] The other possibility is to use $epreq which is a global that always contains the current request object (needs 2.0b11) Gerald --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]