[Templates] How to create Tied hashes?
Subbu Meiyappan
asicjunkie@gmail.com
Wed, 21 Jun 2006 00:04:07 -0700
------=_Part_4838_25696654.1150873447670
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Probably an asked question: How do I create a tied hash so that when I
retrieve the keys, I get it back in the order I inserted inside of TT2?.
Example:
[% hash = {
one = 1,
two = 2,
three = 3
};
%]
[% FOREACH key IN hash.list('keys');
"$key\n";
END;
%]
I'd like it to print
one
two
three
every time, deterministically. In regular perl, we use Tied hashes to
achieve this effect. How do I do this TT? Obviously, I don't want to use the
sort method, since my keys are random.
Thanks
Subbu
------=_Part_4838_25696654.1150873447670
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
<div>Probably an asked question: How do I create a tied hash so that when I retrieve the keys, I get it back in the order I inserted inside of TT2?. Example:</div>
<div> </div>
<div>[% hash = {</div>
<div> one = 1,</div>
<div> two = 2,</div>
<div> three = 3</div>
<div> };</div>
<div>%]</div>
<div> </div>
<div>[% FOREACH key IN hash.list('keys');</div>
<div> "$key\n";</div>
<div> END;</div>
<div>%]</div>
<div> </div>
<div>I'd like it to print</div>
<div>one</div>
<div>two</div>
<div>three</div>
<div> </div>
<div>every time, deterministically. In regular perl, we use Tied hashes to achieve this effect. How do I do this TT? Obviously, I don't want to use the sort method, since my keys are random.</div>
<div> </div>
<div>Thanks</div>
<div>Subbu</div>
------=_Part_4838_25696654.1150873447670--