ПРОЕКТЫ 


  АРХИВ 


Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 


  СТАТЬИ 


  ПЕРСОНАЛЬНОЕ 


  ПРОГРАММЫ 



ПИШИТЕ
ПИСЬМА












     АРХИВ :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Как запустить perl-програ мму в nginx





4 ??????? 2011??. 23:12 ???????????? ????? ??????? <greyhard@xxxxxxxxx> ???????:
?????????? ????? ??????. ???????? ?????? ? GET?? )
use YAML;

sub handler {
? ?my $r = shift;

? ?my %qparam;
? ?my @arr = split('&',uri_unescape($r->args));
? ?for(@arr){
? ? ? ?my @var = split('=',$_);
? ? ? ?$qparam{$var[0]}=$var[1];
? ?}

? ?$r->header_out("Content-Type","text/html; charset=utf-8");
? ?$r->send_http_header();

? ?$r->print(Dump(%qparam));
? ?$r->print($r->uri);

? ?return OK;

}


localhost:80/nginx/test/test/?a=1&b=2

?????????! ??????????. ?????? ???? ??????. ????????????? ??????? ?????:

package perl_module_nginx_my;

use nginx;

sub handler {

? ? my $r = shift;

? ? $r->header_out("Content-Type","text/html; charset=utf-8");
? ? $r->send_http_header();
? ? return OK if $r->header_only;

? ? my %qparam;
? ? my @arr = split('&',$r->args);

? ? for(@arr){
? ? ? ?my @var = split('=',$_);
? ? ? ?$qparam{$var[0]}=$var[1];
? ? }

? ? $r->print("hello!\n<br/>");

? ? $r->print(join(":",%qparam)) ;
? ? $r->print($r->uri);

? ? return OK;

}

1;
__END__
________________________________________________________

?????? ??????:
1.?use YAML ?????????? ?? ??????????. ??? ??????-?? ? ???? ???. ????? ???????? ???? ???????, ?? ? ??? ???? ? ???????? ????? ????????.
2.?uri_unescape ?? ????????, ???????? ?????? ??? ?? ????????? ?????? YAML. ?? ??? ?? ????????. ??? ???????? ??????? ?????????? ? ??? ?????...
3.?Dump ??????-?? ???? ?? ????????. ?? ???? ????? ?? ??? ?????, ?? ??????? ???????? ??????? ????? ????? join.
4. ?? ?????? ???????, ????? ? ??????? ?????? hello ??? ??? ?????? -?return OK if $r->header_only; ?? ?????? ?????? ??????? ?? ? ????.?

________________________________________________________

??????? ?? ??????!


_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://mailman.nginx.org/mailman/listinfo/nginx-ru


 




Copyright © Lexa Software, 1996-2009.