Solved

perl file output could not start from left top?

Posted on 2000-03-13
6
214 Views
Last Modified: 2010-03-05
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;
0
Comment
Question by:syu1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
maneshr earned 50 total points
ID: 2613998
add this line of HTML code before print "<table>";

                   NOTE:    

                   TOPMARGIN and LEFTMARGIN establish margins in MSIE.
                   MARGINHEIGHT and MARGINWIDTH establish margins in Netscape.

                   print "<BODY TOPMARGIN=0 LEFTMARGIN=0 MARGINHEIGHT=0
                    MARGINWIDTH=0> \n";
0
 

Author Comment

by:syu1
ID: 2614415
sorry , I try , it dont work at all!
0
 

Author Comment

by:syu1
ID: 2614517
sorry , I try , it dont work at all!
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:maneshr
ID: 2614545
are you using frames???

0
 
LVL 16

Expert Comment

by:maneshr
ID: 2617218
you have duplicate postings of this question. please delete one of them.
0
 
LVL 3

Expert Comment

by:jyu_88
ID: 2617908
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');
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question