There are some methods to do this:
1) check
$ENV{REQUEST_METHOD}:
if($ENV{'REQUEST_METHOD'} eq 'GET') { $query=$ENV{'QUERY_STRING'} }
elsif($ENV{'REQUEST_METHOD'} eq 'POST') { sysread STDIN,$query,$ENV{'
+CONTENT_LENGTH'} }
else { print 'Unsupport method: '.$ENV{'REQUEST_METHOD'}.'!!!'; }
2) use module
CGI:
use CGI;
my $q = CGI->new();
if(defined $q->param('submit')) {
my $user = $q->param('user_name');
my $pass = $q->param('user_password');
} else {
print "Content-type: text/html\n\n";
print <<END;
<table>
<form method='POST'>
<tr><td>User name:</td><td><input type='text' name='user_name'
+></td></tr>
<tr><td>Password:</td><td><input type='password' name='user_pa
+ssword'></td></tr>
<tr><td colspan=2><input type='submit' name='submit' value=' L
+ogin '></td></tr>
</form>
</table>
END
}
3)
Embperl keeps all passed data into hash
%fdat, and it doesn't matter what method is used in your form.
4)
Mason keeps all passed data into hash
%ARGS
or you can define needed data in the block of code
<%ARGS></%ARGS> and it doesn't matter what method is used in your form.
If you develop small script, in my mind, it's better to use CGI.pm or manual processing of form data. But if you develop site or huge web application it's better to embed Perl using Embperl, Mason or another tool. Because it makes easier developer's life appreciably.
--------------------------------
SV* sv_bless(SV* sv, HV* stash);
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.