----- Original Message -----
From: Harald Ashburner <[EMAIL PROTECTED]>
Date: Thursday, March 10, 2005 11:26 pm
Subject: Preserve order in a HoH

> Greetings,
Hello
> 
> 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.

Why not AoHoHoH, that would use vertualy identical code with small 
modifications ??

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


-- 
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