首先我的英语不是最好的,谢谢你的理解。
代码主体索引的一部分.cgi
my ($url, $params) = split(/?/, $ENV{'REQUEST_URI'});
my @pairs = split(/&/, $params);
foreach $pair (@pairs) {
my ($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$PARAM{$name} = $value;
}
my $consulta = $PARAM{'buscar'};
print CGI::header();
print qq{<div style="font-family: monospace">n};
$mysqltest->buscar($consulta);
print "n<br /><br />n";
print "n</div>n";
模块搜索和结果打印在 cgi -> 索引中.cgi
sub buscar{
my $self = shift;
my $keyword = shift;
die "not work" if not $self->{mysqlopen};
my $queryKeyword = $self->{connect}->prepare("SELECT * FROM savebookmarks WHERE MATCH (url,descripcion) AGAINST ('$keyword');");
$queryKeyword->execute();
while (my $resultKeyword = $queryKeyword->fetchrow_hashref()) {
print dumper_html("$resultKeyword->{id} $resultKeyword->{descripcion} $resultKeyword->{url}");
}
$queryKeyword->finish();
return;
}
索引中的结果打印输出.cgi
...
$VAR1 = 'The Python Standard Library — Python v2.7.2 documentation http://docs.python.org/library/';
$VAR1 = 'python-nmap : using nmap from python http://xael.org/norman/python/python-nmap/';
$VAR1 = 'Manejo de Excepciones en Python « Tutorial Python http://tutorial-python.com.ar/?p=193';
$VAR1 = 'FAQ's de Python - Foros del Web http://www.forosdelweb.com/f130/faqs-python-591053/#post2533652';
...
我有或无法解决的问题是,查询的印象添加了"$ VAR1 ="(它不应该)影响结果,有人来解决它?
这是我需要的完美输出。 ->
...
'The Python Standard Library — Python v2.7.2 documentation http://docs.python.org/library/';
'python-nmap : using nmap from python http://xael.org/norman/python/python-nmap/';
'Manejo de Excepciones en Python « Tutorial Python http://tutorial-python.com.ar/?p=193';
'FAQ's de Python - Foros del Web http://www.forosdelweb.com/f130/faqs-python-591053/#post2533652';
...
添加
local $Data::Dumper::Indent = 0;
local $Data::Dumper::Terse = 1;
在buscar
,最好就在dump_html
线之前。请注意,Data::D umper::HTML 是一个调试工具。