2011-08-25 4 views
0

양식 입력을받을 수있는 코드가있는 http_handler.pl을 호출하는 작은 미니 perl 웹 서버가 있습니다. http_handler에서이 부분perl 스크립트에서 서브 루틴으로 양식 입력을 전달하는 방법

: I가 hello_post.pl 서브 루틴은 사용자 입력을 통과하는 방법

print $fh '<FORM action="/hello_post.pl" method="POST">First Name: <input type="text" name="first_name"> <br> Last Name: <input type="text" name="last_name"> <input type="submit" value="Submit"></FORM>';

...? hello_post.pl (http_handler.pl 또는 pl-websrv.pl 중 하나에서)을 요구해야하지만, 어떻게하면 그 print 서술문을 hello_post.pl 서브 루틴에 전달 된 양식 입력으로 변경 한 다음 그 페이지?

내가 실제로 끝내고 싶은 것은 그냥 다른 이름을 입력/표시하는 것 뿐이지 만 다른 사람들의 코드를 결합하여이 개념을 이해할 수 있는지 확인하고 있습니다. 어떤 도움도 좋을 것입니다. ! 감사! 여기

은 에코 모두 다음과 같은 hello_post.pl 파일 무언가를 작성하여 3 개 개의 파일 (pl-websrv.pl, http_handler.pl 및 hello_post.pl)

http://pastebin.com/iPN3WwqC

답변

0

시작이다 매개 변수의.

#!/usr/bin/perl 
use warnings; 
use strict; 
use CGI::Carp qw(fatalsToBrowser); 
use CGI; 

my $cgi = CGI->new(); 

print "Content-Type: text/plain\n\n"; 

print "hello_post.pl output:\n"; 

my $params = $cgi->Vars(); 
foreach my $arg (sort keys %$params) { 
    print "$arg ==> ", $cgi->param($arg), "\n"; 
} 
관련 문제