jonjacobmoon has asked for the wisdom of the Perl Monks concerning the following question:
Maybe I am going about this wrong, but I think there should be a way to do this. I want to have a hash of array reference so I have the following code snippet: <OUTSIDE LOOP> undef(@selections); while ((my $choice) = $sth->fetchrow_array()) { push(@selections,$choice); } $selections{$_} = \@selections; <END OUTSIDE LOOP> The result of this is that when I undef the array to clear in preparation for the next iteration, I also undef the ref from the previous iteration(s). Then the next ref is created and all values in the hash are the same reference which happens to be the last reference used. So, how do I build an array, put the ref into a hash and then loop back again so I can build up the next array to make a ref to put in the hash and so on.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(Ovid) Re: Array Ref Problem
by Ovid (Cardinal) on Dec 29, 2001 at 04:52 UTC | |
by jonjacobmoon (Pilgrim) on Dec 29, 2001 at 06:47 UTC | |
|
Re: Array Ref Problem
by thor (Priest) on Dec 29, 2001 at 21:57 UTC | |
by jonjacobmoon (Pilgrim) on Jan 01, 2002 at 13:49 UTC |