我正在尝试运行一个 apache Web 服务器,它将获取我的 html 表单,对其进行处理,并给出某种答案。我在安装 cgi 和配置它时遇到了问题,但我设法做到了。现在,当我尝试使用curl 检查perl 脚本时,收到错误“内部服务器错误”。当我检查 apache 错误日志时,它说它由于第 3 行而中止,即:use CGI qw(:standard);
这是我的简单代码:
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
# Enable taint mode
use diagnostics;
print "Content-type: text/html\n\n";
# print header(-type => 'text/html', -charset => 'utf-8').
# start_html('Form Submission Results');
my $sequence = param('sequence');
my $alignment_type = param('alignment-type');
my $organism = param('organism');
my $sequence_length = param('sequence-length');
my $confidence_level = param('confidence-level');
# Check for missing data
if (!$sequence || !$alignment_type || !$organism || !$sequence_length || !$confidence_level) {
print h1("Error: Missing Data");
print p("Please fill all the fields.");
print end_html;
exit;
}
# Basic validation (simulating complex processing)
if ($sequence !~ /^[ACGT]+$/i) {
print h1("Error: Invalid Sequence");
print p("Sequence must contain only A, C, G, or T for DNA.");
print end_html;
exit;
}
# Simulate processing
print h1('Sequence Alignment Results');
print p("Alignment Type: $alignment_type");
print p("Organism: $organism");
print p("Sequence Length: $sequence_length");
print p("Confidence Level: $confidence_level");
print end_html;
我尝试删除 cgi use 行,然后我没有收到错误,但服务器不返回任何内容。
尿尿便便 尿尿便便2x