Well, hashes don't have any order, which may be annoying, if you're trying to get a navigation going (since they may move about, and won't appear in the order you want) so i stuffed them into a list-o-hashrefs
I think a nice way to do this would be with Template Toolkit
my %variables = ( title => 'lookie here', sections=> [ {label=>'DMA',uri=>'dma'} # - - - 8< - - - SNIP - - - >8 - - - ,{label=>'FOMC',uri=>'dma/FOMC'} ] ); # pretty template for our navigation: # note the UNLESS in for the adding of pipes after all but the last li +nk my $template = q{ [% title %]: [% FOREACH link = sections %] <a href="[% link.uri |uri %]">[% link.label %]</a> [% '|' UNLESS loop.last %] [% END %] }; use Template; my $t = Template->new({POST_CHOMP=>1}); $t->process(\$template, \%variables) || die $t->error();
This will give you something a bit like
well, lookie here: DMA |FST |MRA |BKS |MSU |FMA |FOMC
You may want to read Introduction to Template Toolkit (part 3) from merlyn's neat Linux Magazine Columns.
Also, here's a vi regex to make your list into a list of hash refs: :s/\(\w\+\)=>\([^,]\+\)/{label=>'\1',uri=>\2}\r/g
In reply to Re: Turning a hash into a line of links
by f00li5h
in thread Turning a hash into a line of links
by OfficeLinebacker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |