in reply to Re^2: building a hash from a database
in thread building a hash from a database

You're still making the mistake of confusing $rowdata->{$field} with $rowdata{$field}. I fixed that in my code with an update, I admit I only spotted that later. So there was more than one thing wrong with the code. :)

What do you mean by symbolic reference to a new hash?
Well, first of all, you're setting the value of $hash{$id} to, say, 1. And then you set $hash{$id}{'fname'} to "foo". As a result, you really are trying to set $1{'fname'} to "foo".

What I need to be able to do later is to reference the has created like this:
foreach $key (keys %hash) { print $key, $key{'fname'}, $key{'lname'}, +"\n"; }
No way, but you will be able to use
foreach $key (keys %hash) { print $key, $hash{$key}{'fname'}, $hash{$key}{'lname'}, "\n"; }

Replies are listed 'Best First'.
Re^4: building a hash from a database
by bfdi533 (Friar) on May 02, 2006 at 16:20 UTC

    OK, ok, ok. I think I finally understand, finally.

    I had tried that change from earlier and it did not make any difference at that time as I had not accounted for/changed the code to deal with the hashrefs correclty (->). I have now made both changes and it does exactly what I wanted it to.

    I have learned much more about hashes than I realized I did not know.

    Thanks (and thanks for the patience).