I'm barely an intermediate perl programmer so please bear with me. I know what the problem is, I just don't know the syntax to fix it.

I have one script (not listed here) which writes entries to a datafile. The code below is a portion of the script that outputs that same data as a table into a template. On this output page, I want to group entries by neighborhood. Currently, every entry creates a new neighborhood group (not grouping entries with the same neighborhood together. Repeating the same neigborhood) and under each grouping lists every entry regardless of its neighborhood (Repeating information). Hmm... This may sound confusing... You can see the output in action here:

http://www.jyadvertising.com/cgi-bin/homesreadynow_index.cgi

And this is an example of how I am trying to output the page:

http://www.jyadvertising.com/cristohomes/example.html

open (FILE, "$datafile") || &fatal_error("Unable to open $datafile"); &lock(FILE); @messages = <FILE>; &unlock(FILE); close(FILE); for ($a = 0; $a < @messages; $a++) { ($mnum[$a],$maddress[$a],$mimage[$a],$mneighborhood[$a],$mmodelname[$a +],$mmodelelevation[$a],$mbedrooms[$a],$mbathrooms[$a],$mtypeoffoundat +ion[$a],$mschooldistrict[$a],$mprice[$a],$mpaymentsfrom[$a],$mreadyda +te[$a],$mphonenumber[$a],$memail[$a],$chop) = split(/``/,$messages[$a +]); } open (FILE, "$template") || &fatal_error("Unable to open $template"); &lock(FILE); @template = <FILE>; &unlock(FILE); close(FILE); for ($a = 0; $a < @template; $a++) { $_ = $template[$a]; if (/<!--messages-->/) { print "<table width=400 border=0 cellpadding=3 cellspacing=3>\ +n"; print "<tr class=\"typewhite\" bgcolor=\"#000000\">\n"; print "<td><b>Address</b></td>\n"; print "<td><b>Model Name</b></td>\n"; print "<td><b>Price</b></td>\n"; print "<td><b>Availability</b></td>\n"; print "</tr>\n"; foreach $mneighborhood (@mneighborhood) { print "<tr class=\"type\" bgcolor=\"#EEEFDD\"><td colspan= +4><a href=\"../cristohomes/hoods/$mneighborhood.shtml\" class=\"type\ +"><b>$mneighborhood</b></a></td</tr>"; for ($b = 0; $b < @messages; $b++) { print "<tr class=\"type\">\n"; print "<td><a href=\"$indexcgi$queryswitch"; print "action=display\&num=$mnum[$b]\" class=\"red\">$ +maddress[$b]</a></td>\n"; print "<td><a href=\"../cristohomes/homes/$mmodelname[ +$b].shtml\" class=\"red\">\"The $mmodelname[$b]\"</a></td>\n"; print "<td>$mprice[$b]</td>\n"; print "<td>$mreadydate[$b]</td>\n"; print "</tr>\n"; } } print "</table>\n"; } }
I need your wisdom!

update (broquaint): added formatting


In reply to Help? - Trouble outputting data corectly by endsinister

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.