in reply to Array Ref Problem

I also noticed the following:

while ((my $choice) = $sth->fetchrow_array())

You are fetching an array, but storing it in a scalar. You probably want to use the fetchrow_arrayref method. Keep in mind that you cannot simply push the array reference on to an array and hope to use it later, because as I understand it, that method reuses the same array reference on each fetch. In other words, you will get the same array many times when you try to dereference it.

Replies are listed 'Best First'.
Re: Re: Array Ref Problem
by jonjacobmoon (Pilgrim) on Jan 01, 2002 at 13:49 UTC
    Okay, here is it new's years eve and I am writting code. I think I should get extra XP just for that alone : ) Anyway, what I came up with was: <OUTER LOOP> { undef(@selections); while ((my $choice) = $sth->fetchrow_array()) { push(@{ $selections{$_} },$choice); } } <END OUTER LOOP> I tried that arrayref idea, but then I had to deference it again and it just seemed unnecessary unless I misunderstood what you were trying to say. Anyway, this all worked great and I thank all who helped out.