On Fri, 2005-03-11 at 15:26 +1100, Harald Ashburner wrote:
> Greetings,
> 
> I've created a complicated structure using autovification that is
> essentially a hash of hash of hash of hash etc.
> 
> I pass them to the template toolkit where I can get them all out and
> put them in the right place on the page. This all worked well and
> nicely.
> 
> The late mail is that the requirements are to put them on the page in
> the same order that they are read in.
> Is there an easy way to note and preserve ordering in a hash?
> 
> I've had a think about using arrays in stead of hashes but it doesn't
> seem to work easily as far as breaking up the data into sections etc.
> 
> Other solutions that come to mind are:
> create a separate data structure with the {order => key, etc 
> so I would access the strurcture with the data in it by iterating
> through the order datastructure. This would work, but seems a bit
> ugly.
> 
> (note ugly hacks like prepend the order to the key aren't going to cut
> it because I need to use the keys in the template toolkit, where it
> gets ugly to remove the prepeneded stuff.)
> 
> I thought maybe someone might know that there is an easy way and which
> section of the docs it resides. (I don't know much about tie'd
> variables, blessed references etc.
> 
> Bless each hash ref with an ordinal value?
> 
> Thanks for your thoughts.
> 
> 
> -- 
> Kind regards,
> Hal Ashburner
> 

What about using Tie::IxHash?

Regards,

-- 
Marco Antonio Manzo Bañuelos
[EMAIL PROTECTED]
http://www.unixmonkeys.com/amnesiac/



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to