RE: Need help getting started using hashes - SOLUTION

2002-04-17 Thread KEVIN ZEMBOWER
Thank you, David Gray and David K for all your help with understanding hashes. David Gray, the article you referenced at was very helpful. Thank you also for the hash of arrays solution which was just exactly what I was thinking of. Thank you

Re: Need help getting started using hashes

2002-04-16 Thread Dave K
David Gray, Thanks for the input. Below is another realization using a pseudohash. Some of the code (print stmts at the end) is there to demonstrate concepts (the way your post did). my $sql = "select methodid, method, sname from method order by methodid"; my $sth = $dbh->prepare($sql) or die

RE: Need help getting started using hashes

2002-04-16 Thread David Gray
> > my $sql = "select * from method"; > > #replace prev. line with: > my $sql = 'select methodid,method,sname from method'; >$sql .= 'order by methodid'; #second line should be $sql .= ' order by methodid'; -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands,

RE: Need help getting started using hashes

2002-04-16 Thread David Gray
> First let's let the other list member in on the code: > > use DBI; > use strict; > my $dbname = "test"; > my $host = "localhost"; > my $dbuser = ''; > my $dbpw = ''; > my $mscs = "dbi:mysql:dbname=$dbname;host=$host;"; > my $dbh = DBI->connect($mscs, $dbuser, $dbpw) or die "Connect fails to > $

Re: Need help getting started using hashes

2002-04-16 Thread Dave K
First let's let the other list member in on the code: use DBI; use strict; my $dbname = "test"; my $host = "localhost"; my $dbuser = ''; my $dbpw = ''; my $mscs = "dbi:mysql:dbname=$dbname;host=$host;"; my $dbh = DBI->connect($mscs, $dbuser, $dbpw) or die "Connect fails to $dbname\nError = ", $DB

RE: Need help getting started using hashes

2002-04-16 Thread KEVIN ZEMBOWER
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: Lacationa

RE: Need help getting started using hashes

2002-04-16 Thread KEVIN ZEMBOWER
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

RE: Need help getting started using hashes

2002-04-16 Thread KEVIN ZEMBOWER
Thank you, David, very much for your solution. With one minor change ("use DBD::mysql"), it worked perfectly. I am in awe of you ability to do this. I was hoping to use this as a subroutine, to build an array in memory, then to use it repeatedly without rereading the database. Can your solution b