I could be wrong, but it seems to me that line:
if ($Item eq "") {
print "<td>$Item</td>"<td>$Page</td>"<td>$Desc</td>"<td>$Pack</td>"<td>$Price</td>\n";
}
is not correct. You are saying "if $item variable is empty, then print this to the web page". Maybe you planned for $item to be empty, and if so, then to print the stuff to the page, but I'm guessing that's partly why it's not working. If I am wrong, please let me know. Also, That would not print 5 records, per row, it would print 1 record with 5 fields, per row. I'm figuring that is what you want. The code should probably look like this:
#!/perl/bin/perl
print "Content-type:text/html\n\n";
open(INF,"data.txt") or dienice("Can't open data.txt: $! \n");
@grok = <INF>;
close(INF);
print <<EndHdr;
<html><head><title>My Data</title></head>
<body>
<center>
<h2 align="CENTER">My Data</h2>
<table border="1">
<tr>
EndHdr
foreach $i (@grok) {
chomp($i);
($Item,$Page,$Desc,$Pack,$Price) = split(/\|/,$i);
# /* Changed The Line Below */
if ($Item ne "") {
print "<TR><td>$Item</td>"<td>$Page</td>"<td>$Desc</td>"<td>$Pack</td>"<td>$Price</td></TR>\n";
}
}
print <<EndFoot;
</tr>
</table>
</center>
</body>
</html>
EndFoot
sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print $msg;
exit;
} Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215