scott wrote:
> Jim Gibson wrote:
>> On 7/10/09 Fri  Jul 10, 2009  2:25 PM, "Shawn H. Corey"
>> <shawnhco...@gmail.com> scribbled:
>>
>>> On Fri, 2009-07-10 at 15:19 -0600, Scott wrote:
>>>> Hello,
>>
>>>> Here is my code on the perl side:
>>>>
>>>> my @wall_data = ();
>>>> while(my $wallref = $wallpostquery->fetchrow_hashref())
>>>> {
>>>> my %walldata;
>>>>
>>>> $walldata{WALL_SUBJECT} = $wallref{'SUBJECT'};
>>>> $walldata{WALL_DATE} = $wallref{'DATE'};
>>>> $walldata{WALL_POSTID} = $wallref{'POSTID'};
>>>> $walldata{WALL_MESSAGE} = $wallref{'MESSAGE'};
>>>>
>>>> push (@wall_data, \%walldata);
>>> # The above pushes the address of hash on the array, over and over
>>> again.
>>
>> Which works because %walldata is localized to the while loop and is
>> re-allocated each time through the loop. Each loop iteration creates a
>> new
>> hash variable, and the array @wall_data contains a list of distinct hash
>> references.
>>
>>>                  push @wall_data, { %walldata };
>>> # This code pushes an anonymous hash containing the data on to the
>>> array.
>>
>> Which also works, because a copy of the hash is saved, but it is not as
>> efficient.
>>
>> In other words, the problem lies elsewhere. As far as I can tell the
>> code is
>> fine as shown, but I don't have any experience with HTML::Template.
>>
>>
>>
> I found the error, seems to not be putting the stuff into the hash right
> or something. I found a fix so thought i should put it on the list.
> Here is an example i found after digging around on google:

Aside from what you've found, it may help if you review a thread I
recently started:

http://osdir.com/ml/perl-beginners/2009-06/msg00295.html

Cheers,

Steve


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to