001 AA Aardvark
002 AA Acme
003 BB Bellisimo
004 BB Bull
005 CC Carp
006 CC Cisco
..
757 ZZ Zebra
What I want to do is display a range from the database based on the SECOND column (AA,BB,CC,etc.) so that lines ranging from AA to GG would be displayed. They would then be sorted by the THIRD column (alphabetically).
I have a basic script that simply displays the entire database alphabetically based on the third column, but can't figure out the best way to limit the results to a fraction of the entire list...
Here's the script I have so far:
open(INFO, "database.txt");
@array=<INFO>;
close (INFO);
print "Content-type:text/html\n\n";
print <<End_of_Head;
<html>
<head><title></title></head>
<body>
End_of_Head
foreach $line(sort byNUM @array){
chomp($line);
($num,$cat,$name)=split(/\t/,$line);
print <<Endofline;
$name
Endofline
}
print <<End_of_Doc;
</body>
</html>
End_of_Doc
### Sorting Subroutine ###
sub byNUM {
@a=split(/\t/,$a);
@b=split(/\t/,$b);
$a[2] cmp $b[2];
}

