in reply to Re^2: Turning a hash into a line of links
in thread Turning a hash into a line of links

I think at that point, it would be better to just maintain a real order, via a list, and associating values as part of an array ref.
my @sections = ( [DMA => 'dma'], [FST => 'dma/fst'], [MRA => 'dma/mra'], [BKS => 'bks'], [MSU => 'dma/msu'], [FMA => 'dma/fma'], [FOMC => 'dma/FOMC'], ); my @la = map { a( {-href => "/$_->[1]"}, "$_->[0] HOME" ) } @sections; print join "\n|", @la;
In fact that's probably better than the key-mangling for this number of keys too.

Replies are listed 'Best First'.
Re^4: Turning a hash into a line of links
by johngg (Canon) on Dec 13, 2006 at 11:36 UTC
    The problem with that is you lose the ability to do look-ups so you have to iterate over the array to find the 'FMA' key/value pair. You could keep the hash but make it a HoH with the sort order held inside, like

    my %sections = ( DMA = {attrib => q{dma}, sortOrder => 1}; ...

    but that strikes me as more complicated when most keys don't need it, just those with an odd ordering requirement.

    Cheers,

    JohnGG