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

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?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,120809,120809#msg-120809

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 D.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs