CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [allan1962] Creating alphabetic Sort: Edit Log



allan1962
Novice

Jun 4, 2007, 9:38 AM


Views: 5094
Re: [allan1962] Creating alphabetic Sort

Ok This is what I have so far

*********************************************************

open(DATABASE, "datafiles/data.txt") || die "Can't open input";
$count=0;
@data=<DATABASE>;
close (DATABASE);

foreach $data(@data)
{

($Category) = split(/\|/, $data);
push @db_searchresults, $data;
}

foreach $data1(@db_searchresults)
{

chop ($data1);
($Category) = split(/\|/, $data1);
push @db_Category, $Category;

$count++;
$urllink="";
$nextletter=0;

@letters = ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', );
}


if("$db_Category[0]" eq ""){ print "<BR><div align=center><b><i>No Entry</b><br></div>";
}

$start = "$in{'start'}";

$letters[$nextletter];
while ($count) {
$listing[$i] = substr("$db_Category[$i]",0,1);

if("$letters[$nextletter]" eq "$listing[$i]")
{ $urllink[$i] = "<a href='../listing/display.cgi?search=1&searchtype=all&searchtext=$db_Category[$i]'>$db_Category[$i]</a>";
print qq!
<TR valign="top">
<TD class="category">
$urllink[$i],
</td></TR>
!;
}
else {
$nextletter++;
}
$i++;
--$count;
}
**************************************************************************

Results at http://www.peibd.com/cgi-bin/testdata/data2.cgi

I'm getting close, but still missing something in the comparing the first letter.

As you can see, and an earlier post hinted at, I am trying to make an effort here.

Can someone help me with the final steps?


(This post was edited by allan1962 on Jun 4, 2007, 10:11 AM)


Edit Log:
Post edited by allan1962 (Novice) on Jun 4, 2007, 9:55 AM
Post edited by allan1962 (Novice) on Jun 4, 2007, 10:11 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives