Is there any way to use a nginx variable inside a perl set?

Maxim Dounin mdounin at mdounin.ru
Wed Aug 18 04:16:17 MSD 2010


Hello!

On Tue, Aug 17, 2010 at 05:18:20PM -0400, evms wrote:

> Let's imagine that I do this
> 
> http {
> set $a 2;
> perl_set $x sub { return $a++; } 
> }
> 
> I don't think I can do this. Is there away around this to provide that
> functionality?

Something like this should work (not tested):

perl_set $x "sub {
                 my $r = shift;
                 my $a = $r->variable{'a'};
                 $a++;
                 $r->variable('a', $a);
                 return $a;
             }";

See here for details:

http://wiki.nginx.org/NginxEmbeddedPerlModule

Maxim Dounin



More information about the nginx mailing list