发新话题
打印

[perl] html 怎么才能把参数传进perl内?

html 怎么才能把参数传进perl内?

<html>
<title> perl example </title>
<body>
<form method="get" action="/cgi-bin/changepasswd.pl">
UserName <INPUT type="text" name="first" SIZE=25><BR>
PassWord <INPUT type="password" name="last" SIZE=25><BR>
<input type="submit" name="StateVariable" value="test it">
</form>
</body>
</html>


怎么才能把username 和password的数据传入perl呢?

#!/usr/bin/perl -w
($username,$plaintext) = @_;                                       #我在这里print $username 和$plaintext全是空的
print "Content-type:text/html\n\n";
srand (time());
my $randletter = "(int (rand (26)) + (int (rand (1) + .5) % 2 ? 65 : 97))";
my $salt = sprintf ("%c%c", eval $randletter, eval $randletter);
#my $plaintext = 1234567890; #shift;
my $crypttext = crypt ($plaintext, $salt);
print "${crypttext}:cvsroot\n";
#print "please input username:\n";
#chomp($username=<STDIN>);
#print "username is: $username\n";
#$username=submit;
my $FoundFlag="False";
my $pwdFile='passwd';
my $tmpPwdFile='temp.tmp';

TOP

STDIN里面读阿
其中环境变量有
GET:
QUERY_STRING
REDIRECT_QUERY_STRING
POST:
CONTENT_LENGTH
CONTENT_TYPE

example:
复制内容到剪贴板
代码:
    if ($method eq 'GET' || $method eq 'HEAD')
    {   
        if ($SYSTEM{MOD_PERL})
        {
            $query_string = Apache->request->args;
        }
        else
        {
            $query_string = $ENV{'QUERY_STRING'} if (defined($ENV{'QUERY_STRING'}));
            $query_string ||= $ENV{'REDIRECT_QUERY_STRING'} if (defined($ENV{'REDIRECT_QUERY_STRING'}));
        }
    }
    elsif ($method eq 'POST')
    {   
        sysread(STDIN, $query_string, $content_length);
    }   
    elsif (defined($ARGV[0]))
    {   
        $query_string = join('&', @ARGV);
    }   
[ 本帖最后由 cnangel 于 2008-8-24 14:13 编辑 ]
print pack( 'H*', '436e616e67656c');
http://renark.huhoo.net/crypt.cgi

TOP

web高手cnangel
学习学习
Once upon a man.

TOP

发新话题