Bill Conlon wrote:
> Thanks, the hash reference gets pushed onto the list, and now exposes
> more of my ignorance.
> Say I have three rows returned by my SQL query. The while loop
> properly generates three hashes, and @servers grows to contain three
> elements, but each has the same hash reference, which ends up pointing
> to the last created hash. How do I programatically generate a series
> of hash references?
You have to localize the scope of the new hash that you are creating
using 'my'. If you don't then a new hash isn't created for each iteration.
while (@ary = $sth->fetchrow_array ())
my %hash = (
base_url => $ary,
max_depth => $ary,
push @servers, \%hash;
> On Monday, November 22, 2004, at 06:34 PM, Bill Moseley wrote:
>>On Mon, Nov 22, 2004 at 04:41:11PM -0800, Bill Conlon wrote:
>>>I'm trying it along these lines:
>>>while (@ary = $sth->fetchrow_array ())
>>>%hash = (
>>> base_url => $ary,
>>> max_depth => $ary,
>>> push @servers, %hash;
>> push @servers, \%hash;
>>You want to push a hash reference on the list.
>>Unsubscribe from or help with the swish-e list:
>>Help with Swish-e:
Plus Three, LP
Received on Wed Nov 24 12:11:19 2004