Jaxonn has asked for the wisdom of the Perl Monks concerning the following question:
Perl Monk, Andrew Jackson#!c:/perl/bin/perl print "Content-type: text/html\n\n"; use CGI; ####################################################### ## © Copyright 2002 All Rights Reserved ## ## Mr. Andrew Jackson ## ####################################################### ####################################################### ##This little bugger here takes the .txt database and## ##sorts it in alphabetical order from A to Z ## ####################################################### open(items, "itemdat.txt") or die "could not open file"; @list1 = <items>; close(items); $kn = 0; for ($nk = 0; $nk <= $#list1; $nk){ $item1 = @list1[$nk]; chomp($item1); $nk++; $item2 = @list1[$nk]; chomp($item2); $nk++; $item3 = @list1[$nk]; chomp($item3); $nk++; $item4 = @list1[$nk]; chomp($item4); $nk++; $item5 = @list1[$nk]; chomp($item5); $nk++; @list[$kn] = "$item1&$item2&$item3&$item4&$item5"; $kn++; } $nk = 0; foreach $list (@list){ local($item1, $item2, $item3, $item4 ,$item5) = split(/&/, $list) +; @list1[$nk] = "$item1 \n"; $nk++; @list1[$nk] = "$item2 \n"; $nk++; @list1[$nk] = "$item3 \n"; $nk++; @list1[$nk] = "$item4 \n"; $nk++; @list1[$nk] = "$item5 \n"; $nk++; } open(items, ">itemdat.txt"); print items "@list1"; close(items); #################################### ##This is the end of little bugger## #################################### print "<title>Diablo II Broth - Items</title><body bgcolor='black' tex +t='white'>"; open(items, "itemdat.txt") or die "could not open file"; @contetnsoffile = <items>; close(items); $nk = 0; print "<font style='font-size: 23; font-family: Tahoma; color: Blue'>< +center>The Items We Own as of Now<br><font style='font-size: 12; colo +r: red'>In the order entered into the database</font></center></font> +<p> "; print "<center><table width='60%' border='0'>"; print "<td align='center'><b><font color='green'>Name</font></b></td>< +td align='center'><b><font color='green'>Status</font></b></td><td al +ign='center'><b><font color='green'>Type</font></b></td><td align='ce +nter'><b><font color='green'>Mods</font></b></td><td align='center'>< +b><font color='green'>Quanity</font></b></td><tr>"; $color = "red"; for ($nk = 0; $nk <= $#contetnsoffile; $nk){ print "<td width='40%' align='center'><font color='$color'>@ +contetnsoffile[$nk]</font></td>"; $nk++; print "<td width='15%' align='center'><font color='$color'>@ +contetnsoffile[$nk]</font></td>"; $nk++; print "<td width='15%' align='center'><font color='$color'>@ +contetnsoffile[$nk]</font></td>"; $nk++; print "<td width='25%' align='center'><font color='$color'>@ +contetnsoffile[$nk]</font></td>"; $nk++; print "<td width='5%' align='center'><font color='$color'>@c +ontetnsoffile[$nk]</font></td><tr>"; $nk++; if ($color eq red){ $color = "blue"; } else { $color = "red"; } } print "</table></center>";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Alphabetical order with .txt file
by grep (Monsignor) on Apr 16, 2002 at 23:28 UTC | |
by Jaxonn (Initiate) on Apr 18, 2002 at 02:19 UTC | |
|
Re: Alphabetical order with .txt file
by lemming (Priest) on Apr 17, 2002 at 01:21 UTC | |
|
Re: Alphabetical order with .txt file (boo)
by boo_radley (Parson) on Apr 17, 2002 at 02:03 UTC | |
by Jaxonn (Initiate) on Apr 17, 2002 at 22:10 UTC |