Link to home
Start Free TrialLog in
Avatar of syu1
syu1

asked on

perl file output could not start from left top?

I use the following perl file , use table , try to output datafile, how come the
output html fail to start from left-top corner? how to format it start from the left-top beginning?


#!/usr/local/bin/perl  

require "cgi-lib.pl";

# Use the
use Getopt::Long;
use English;
use AnyDBM_File;


print "Content-type: text/html\n\n";
print"<html>\n";
print"<head>\n";

print"<title>please fill out</title>";
print"</head>";

print"<body>";

# Set up the command line options.
my $ret            = GetOptions ("d|database:s");

my $database   = "convert.dbm";
my (%contents,$count,$type,$name,$price,$desc,$record);

# Open the DBM database file.
dbmopen (%contents, $database, 0700) || die "Could not open DBM file $database : $!\n";

# Force the top of page.
$FORMAT_LINES_LEFT = 0;
$count = 0;



print"<table>";

      print "<tr>";
        print"<td>Count Item # </td>";
        print"<td>Item Type </td>";
        print"<td>Item Name </td>";
        print"<td>Price </td>";
        print"<td>Description</td>";
        print"</tr>";


# Start printing out the dbm information.
for $number (sort keys %contents)
{
   # Get the contents from the hash.
   $record = $contents{$number};

   # Split the record up.
   ($type,$name,$price,$desc) = split (/\|/, $record);
   $count++;

   # Write it...
      #write
      print "<tr>";
      print"<td> $count</td>";
      print"<td> $type</td>";
      print"<td> $name</td>";
      print"<td> $price</td>";
      print"<td> $desc</td>";

      print"</tr>";
      print"<br>\n";

}

print"</table>";
print"</body>\n";

print"</html>\n";


# Close the DBM database.
dbmclose %contents;
ASKER CERTIFIED SOLUTION
Avatar of maneshr
maneshr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of syu1
syu1

ASKER

sorry , I try , it dont work at all!
Avatar of syu1

ASKER

sorry , I try , it dont work at all!
are you using frames???

you have duplicate postings of this question. please delete one of them.
run it from the command line and capture the HTML to a file. try to view the file yourself and also post the HTML here.

CGI.pm is preferred over old cgi-lib.pl.
-cut-----cut------cut-----cut---
#! /usr/bin/perl -w
use CGI;
my $query = new CGI;
print query->header(-type=>'text/html');
print $query->start_html(-title=>'please fill out');