Search code examples
template-toolkit

How do I get a random number in template toolkit?


I want to get a random number using template toolkit. It doesn't have to be particularly random. How do I do it?


Solution

  • From this post at Slashcode:

    [slash@yaz slash]$ perl -MSlash::Test -leDisplay
    [%
    digits = [ 0 .. 9 ];
    anumber = digits.rand _ digits.rand _ digits.rand;
    anumber;
    %]
    ^D
    769