lapsan has asked for the wisdom of the Perl Monks concerning the following question:

I have created a script (based on the chemiserie shopping cart script in Chapter 19 of the Cookbook) and have come across a problem. The problem is that, in Netscape anyway, the table I'm building (see the code below) is pushed way down the page in the browser instead of being rendered where it should at the top of the page.

I am pretty sure the distance down the page is related to the amount of time it takes to read in the file and generate the table based on the info in the file. Is there any way around this that anyone knows of? Is there a better way for me to do this?

(The results can be seen by visiting http://www.lapsan.com/intranet/scratch/test2.pl and clicking on "MasterList") ------ I'm reading in a file as follows (if this is wrong, could someone give me a heads up?):
open (INDATA, "master.job.list") or die "Couldn't read file $!\n"; while (<INDATA>) { @temp = split/:/; push @data, [ @temp ]; } close (INDATA);
Then, I'm printing the opening HTML, beginning an HTML table and doing the following:
$clientname_temp = ""; foreach $line (@data) { $clientname = $$line[0]; $jobnumber = $$line[1]; $description = $$line[2]; if ($clientname_temp ne $clientname) { print "<TR bgcolor='#ffffcc'><TD COLSPAN=4 bgcolor='#ffffcc'>< +B>$clientname</B></TD></TR>\n$ print "<TR><TD>EDIT DELETE</TD><TD><B>Job Number</B> = $jobnum +ber</TD><TD><B>Description</B$ } else { print "<TR><TD>EDIT DELETE</TD><TD><B>Job Number</B> = $jobnum +ber</TD><TD><B>Description</B$ } $clientname_temp = $clientname; }
Of course, I'm closing the HTML and all that.

Replies are listed 'Best First'.
Re: Odd HTML printing - Perl's fault?
by Fastolfe (Vicar) on Oct 25, 2000 at 00:04 UTC
    This is the result of bad HTML:
    <TR> <TD>EDIT DELETE</TD> <TD><B>Job Number</B> = 111098</TD> <TD><B>Description</B> = Direct mail to non-customers - design, copy, FA</TD> <TD>DETAILS</TD> </TR><BR>
    That trailing <br> is outside of all of your <table> elements (<tr> and <td>). As a result, its behavior is undefined and your browser is rendering it before rendering the completed table. The result is equivalent to a bunch of <br> tags before your <table> tag. In any event, since <tr>...</tr> by definition defines a row, the <br> is unnecessary and out of place.

    So no, this is not Perl's fault.

Re: Odd HTML printing - Perl's fault?
by AgentM (Curate) on Oct 25, 2000 at 00:11 UTC
    While you're at it, why not convert your table info to use CGI's table functions- you'll end up with easier2debug code than lines of HTML where a single typo can result in ?????

    Perhaps its too late, but since you asked for advice- use a real database such as the standard SDBM_File or some dbengine. You'll thank it in the long run- especially for online shopping!

    AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.
    A reply falls below the community's threshold of quality. You may see it by logging in.