Perl and Data::Dumper::HTML + cgi

644 Views Asked by At

First of all my english is not the best, thank you for understanding.

A portion of the code principal 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";

Module Search and result is print in 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;
}

Result print output in 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';
...

The problem that I have or I can not resolve is, the impression of the query adds '$ VAR1 =' (it should not be) affecting the result, some one to fix it?


this is perfect output i need. ->

...
'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';
 ...
1

There are 1 best solutions below

1
On

Add

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

in buscar, preferably right before the dump_html line. Note that Data::Dumper::HTML is a debugging tool.