perl cgi
岳高明
2023-12-01
#!/usr/bin/perl
print "Content-type:text/html/n/n";
if ($ENV{'REQUEST_METHOD'} eq "POST") {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
} else {
$buffer = $ENV{'QUERY_STRING'};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value=~s//././/g;
$FORM{$name} = $value;
}
$qmonth=$FORM{'tmonth'};
print <<EOF;
<p>sddddddddddddddddddddd</p>
<form action="test.pl" method="post">
pls input the month:
<input type="TextBox" name="tmonth"><input type="submit"><BR>
</form>
<p>----------------------------------<p>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=1>
<TBODY>
<TR>
<TD width="30%">Testor Name </TD>
<TD width="30%">Compont Name </TD>
<TD width="40%">BUG ID </TD>
</TR>
EOF
@result=&getBUGNum($qmonth);
for($item=0;$item<@result;$item++)
{
print "<TR>";
print "<TD>ddddddddddddd</TD>";
print "<TD>ddddddddddddd</TD>";
print "<TD>$result[$item]</TD>";
print "</TR>";
}
print <<EOF;
</TBODY>
</TABLE>
EOF
exit;
sub getBUGNum
{
open(MYFILE,"logfile");
@test1= <MYFILE>;
$num=@test1;
%result={};
$flag="0";
for($n=0; $n<$num; $n++)
{
$item=$test1[$n];
chop $item;
$s=substr($item,0,8);
if($s=~ /(/d{4})(/d{2})(/d{2})$/)
{
$date="$1$2";
if( $_[0] eq "$1$2")
{
$flag="1";
}else{
$flag="0";
}
if($flag eq "1")
{
$s1=substr($item,9,);
while($s1=~ /([0-9]+)/g)
{
$BN=$&;
$result{$BN}=1;
}
}
}
}
keys(%result);
}