The question cannot be easier as I have trouble to print text in a perl
script.
Below you'll find the script, which interacts with a MySQL database, to
retrieve some names and prints them to the client
Here's the script
###############################################################.
#!/usr/bin/perl
use CGI;
use strict;
use DBI();
my $q = new CGI;
print $q->header();
print "<html><body bgcolor=00FFAA>This appears well<br>";
# Connect to the database.
my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost",
"dbuser", "dbpassword",
{'RaiseError' => 1});
print "This doesn't appear<br>";
# Now retrieve data from the table.
my $sth = $dbh->prepare("SELECT * FROM foo");
$sth->execute();
while (my $ref = $sth->fetchrow_hashref()) {
print "Found a row: id = $ref->{'id'}, name = $ref->{'name'}\n";
print "This doesn't appear either<br>\n";
}
$sth->finish();
# Disconnect from the database.
$dbh->disconnect();
print "This doesn't appear either<br>\n";
print "</html>\n";
###############################################################.
The script is very simple and can be tested at
http://www.recordamelo.com/cgi-bin/example.cgi
If I run the script from the command line and the answer (as it should be)
is:
Content-Type: text/html; charset=ISO-8859-1
<html><body bgcolor=00FFAA>This appears well<br>This doesn't
appear<br>Found
a row: id = 1, name = Tim
This doesn't appear either<br>
Found a row: id = 2, name = Jochen
This doesn't appear either<br>
This doesn't appear either<br>
</html>
Whereas when called from the web, the script answers:
<html><body bgcolor=00FFAA>This appears well<br>
Where is the missing html?
I did an upgrade of my operating system (including the perl distribution),
and after that several cgi's stop to work showing the same problem.
I was wondering if some module is missing.
Thanks to anyone who can clarify this puzzle!
Alejandro