I am trying to modify the List Categories & Count Mod. I have it working beautifully for one field, but for my second attempt I'm trying to sort by one field (author_last) and display by another (author_full). I have a lovely theory on how I'm going to do this (2 or 3 have already failed) but I'm having trouble figuring out what's going on in one of these lines so that I can tinker with it.
Here's the actual code.
if ($found) {
open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $ !");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
++$count{$fields[$fieldnum]};
}
close DB;
##Here's my loose translation of what's happening
## If the field to sort by exists, then...
##open the .db file
## and, if possible, lock the file.
## While there's still more stuff in the .db file, grab the next line.
## If the line starts with #, go on to the next line.
## Likewise, if the line starts with whitespace, go on to the next line.
## Otherwise, assign the line to the variable $line,
## and trim off the unwanted stuff at the end.
## Let the subroutine &split_decode break the line into fields and assign them to the fields array.
## What does this do? ++$count{$fields[$fieldnum]};
I know that count is a hash, and that *something's* getting incremented, but I can't see what's being put into the hash.
I *think* what I want in this hash is author_last keyed to author_full. Then I *should* be able to figure out how to sort by author_last and display by author_full. But since I don't know what's happening now, I don't know how to tinker with it...
Thanks for any help.
Kristen Skold
Here's the actual code.
if ($found) {
open (DB, "<$db_file_name") or &cgierr("unable to open $db_file_name. Reason: $ !");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
next if /^#/;
next if /^\s*$/;
$line = $_;
chomp ($line);
@fields = &split_decode ($line);
++$count{$fields[$fieldnum]};
}
close DB;
##Here's my loose translation of what's happening
## If the field to sort by exists, then...
##open the .db file
## and, if possible, lock the file.
## While there's still more stuff in the .db file, grab the next line.
## If the line starts with #, go on to the next line.
## Likewise, if the line starts with whitespace, go on to the next line.
## Otherwise, assign the line to the variable $line,
## and trim off the unwanted stuff at the end.
## Let the subroutine &split_decode break the line into fields and assign them to the fields array.
## What does this do? ++$count{$fields[$fieldnum]};
I know that count is a hash, and that *something's* getting incremented, but I can't see what's being put into the hash.
I *think* what I want in this hash is author_last keyed to author_full. Then I *should* be able to figure out how to sort by author_last and display by author_full. But since I don't know what's happening now, I don't know how to tinker with it...
Thanks for any help.
Kristen Skold

