<div dir="ltr">Английская дока, насколько вижу, полностью соответствует русской.<div><br></div><div>Я сделал так, но не работает:</div><div><br></div><div><div><font face="monospace, monospace">http {</font></div><div><span class="" style="white-space:pre"><font face="monospace, monospace">       </font></span></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">    </span>perl_set $outer_variable '</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">              </span>sub {</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">                       </span>my $r = shift;</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">                      </span>return "=" + $r->variable("inner_variable")  + "=";</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">               </span>}</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">   </span>';</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">      </span>location / {</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">                </span>perl '</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">                  </span>sub {</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">                               </span>my $r = shift;</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">                              </span>$r->variable("inner_variable", "CCCC");</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">                      </span>}</font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">           </span>';</font></div><div><span class="" style="white-space:pre"><font face="monospace, monospace">              </font></span></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">            </span>add_header X-MY-VAR "$outer_variable";</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace"><span class="" style="white-space:pre">    </span>}</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">}</font></div></div><div><br></div><div>При правильном выполнении должен проставиться заголовок X-MY-VAR равный =CCCC=, но по факту ставится число 0.</div><div>Если убрать "=" из return, то заголовок просто не ставится (видимо, пустая переменная).</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-07-16 11:12 GMT+03:00 Daniel Podolsky <span dir="ltr"><<a href="mailto:onokonem@gmail.com" target="_blank">onokonem@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">2015-07-16 0:51 GMT+03:00 Michael Kechinov <<a href="mailto:kechinoff@gmail.com">kechinoff@gmail.com</a>>:<br>
> Внутри location делаю вставку perl, в которой что-то рассчитывается и<br>
> результат нужно передать в переменную внутрь location. Как это можно<br>
> сделать?<br>
</div></div><a href="http://nginx.org/ru/docs/http/ngx_http_perl_module.html#perl_set" rel="noreferrer" target="_blank">http://nginx.org/ru/docs/http/ngx_http_perl_module.html#perl_set</a><br>
<br>
английский вариант этой доки, надо сказать, более внятный<br>
<br>
так вот, perl_set позволяет создать квазипеременную, при упоминании<br>
которой в конфиге будет вызываться ваш перловый код. при каждом<br>
упоминании.<br>
<br>
соответственно, если вызвать код надо один раз на запрос - используйте<br>
set в сочетании с perl_set<br>
_______________________________________________<br>
nginx-ru mailing list<br>
<a href="mailto:nginx-ru@nginx.org">nginx-ru@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-ru" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-ru</a></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><b><a href="http://linkedin.com/in/mkechinov" target="_blank">Michael Kechinov</a></b> | <a href="mailto:sam@mkechinov.ru" target="_blank">sam@mkechinov.ru</a> | +7 950 0099233<br><div>Startups development studio: <a href="http://mkechinov.ru/" target="_blank">mkechinov.ru</a> | <a href="http://mkechinov.com" target="_blank">en</a></div><div>Personalization for e-commerce: <a href="http://rees46.com" target="_blank">rees46.com</a></div><div>HackDay: <a href="http://hackday.ru/" target="_blank">hackday.ru</a> <br>Twitter-wall: <a href="http://twijector.com" target="_blank">twijector.com</a></div></div></div>
</div>