سؤال

I need to declare an array in my Perl catalyst template file like we declare it in our Perl eg: @array = (1..100); Can someone help me with that [% $array = (1..100)%]

هل كانت مفيدة؟

المحلول

[% a = [0..8] %] [% a.5 %] will print 5.

نصائح أخرى

If you are using Template Toolkit, you can initialize an array like this:

[% myarray = [ 1 .. 100 ] %]

OR

[% x=1
   y=100
   myarray = [ x..y ] %]

For more info on arrays and TT (Template Toolkit) you can have a look here:

http://template-toolkit.org/docs/manual/Variables.html#section_List_References

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top