[Cedarvalley] storing a hash in a list...

Stephen D. Wells wells at cedarnet.org
Mon Nov 17 18:32:46 CST 2003


My cedarnet email was down and I don't know if a response has been
generated yet however this is a detailed account of what is happening
and how to avoid it:

using @list = \%hashed_data stores a pointer to that data.  Meaning that
it's not a copy but a link.  What you need is exactly what you said... a
copy to a reference.  The reason is that each time you go through the
list you are pointing to the same data...

Try this instead:

push(@list, {%hashed_data});

STEVE

On Thu, 2003-11-13 at 23:42, Aaron Thompson wrote:
> I am building a hash as I loop thru some data.. and would like to
> store that hash in another list for later use. I'm having trouble
> getting the hash to store properly. Any one know how to return a
> reference to a copy of a hash?
> 
> I started with:
>   @list = \%hashed_data 
> 
> but found that I got lots of references to the same data
> I tried:
> 
>   @list = \%{%hashed_data} 
>   
> This had the sam results.
> 
> Thanks,
> 
>   @
-- 
Stephen D. Wells <wells at cedarnet.org>




More information about the Cedarvalley mailing list