Well, I guess I spoke too soon. I still don't understand something.

When I execute your program, David,  it returns this
www:/cire # ./methodtest3.pl 
Key: 1   Value: Combined OCs
Key: 10   Value: Diaphragm Cervical Cap
Key: 11   Value: Fertility Awareness-based Methods
Key: 12   Value: Lacational Amenorrhea Method (LAM)
Key: 2   Value: Progestin-Only OCs
Key: 3   Value: DMPA/NET EN
Key: 4   Value: Norplant Implants
Key: 5   Value: Female Sterilization
Key: 6   Value: Vasectomy
Key: 7   Value: Condoms
Key: 8   Value: TCu-380A IUD
Key: 9   Value: Spermicides
www:/cire # 

>From the code, I think you're using the first field returned from the
database as the key, and the second field as the value, but then
discarding the third field. Am I understanding this correctly? I need to
be able to recall all three parts of the information as needed. This is
why I'm thinking this is a hash of arrays, with the hash key being the
methodid, and the hash value being an array of methodid, method and
sname.

Thanks, again, for all your help. I'm certain my difficulty in
understanding is due to my abilities, and not your explanations.

-Kevin

>>> "KEVIN ZEMBOWER" <[EMAIL PROTECTED]> 04/16/02 11:50AM >>>
David, your revisions made your solution even more clear to me. With
regard to my earlier question of using this in a subroutine, I think I
now see that %thehash would be my persistent repository for methods,
and
that I could refer to it just like you did in the last three lines,
without rereading the database.

Thank you, again, for your help.

-Kevin

>>> "David Kirol" <[EMAIL PROTECTED]> 04/16/02 11:29AM >>>
Kevin,

Hope the script I sent earlier helped expose you to some of the hash
and
reference stuff.
I re-read your post and it occured to me you requirement was not that
complex (but, perl is partly about fun...)

Finally, when I've got the hash built, how can I get a particular
method, by specifying it's methodid, or instance?

Thanks for your help and suggestions. Please let me know if I should
take this question to the DBI-users list.

This suggests, IMHO, you need to select a key field from the method
table
and a value field.
If you choose id as the key and method as the value you could
substitute the
code below
into the script I sent earlier, and it should be a bit more on target.

my %thehash;
my @row_ary;
my $row_ary;
my $key;

while (@row_ary  = $sth->fetchrow_array) {
        $key = $row_ary[0];
        $thehash{$key} = $row_ary[1];
}
$sth->finish;
$dbh->disconnect;
# all dbi stuff is done, show the hash
foreach $key (sort keys %thehash) {
        print"Key: $key   Value: $thehash{$key}\n";
}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to