0

首先我的英语不是最好的,谢谢你的理解。

部分代码主体 index.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 -> index.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;
}

index.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';
 ...
4

1 回答 1

1

添加

local $Data::Dumper::Indent = 0;
local $Data::Dumper::Terse  = 1;

in buscar,最好在该dump_html行之前。注意 Data::Dumper::HTML 是一个调试工具。

于 2012-10-11T17:29:57.300 回答