Richard Mace wrote:
>
> I have a hash in my CGI script, e.g. $info{$filename} = $filepath;
> (hash contents e.g.
> KEY: one.html, VALUE: /REPORTS
> KEY: two.html, VALUE: /REPORTS
> KEY: three.html, VALUE: /REPORTS
> KEY: four.html, VALUE: /REPORTS ).
>
> I'm passing the $info hash to my tt2 script and in this script I have ...
>
> [% FOREACH project = info %]
> <A HREF="[% project.value %]/[% project.key %]">[% project.key %]
> [% END %]
>
> At present the output is printed in this order .....
> four.html
> one.html
> three.html
> two.html
>
> How can I ensure that this list is printed in number order i.e.
> one.html
> two.html
> three.html
> four.html
In Perl, the keys of a hash are never sorted in any
particular order. So your main problem is the limitation of
the data structure you are using. You could use Tie::IxHash
where you have control over ordering of hash keys. Or you
could think about creating a different data structure,
something like an array of hashes.
HTH, Hans
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates