Hi
I think I may have found a bug when using the split function because I believe that I am using it according to theTemplate Documentation, but I could be doing something really stupid here. Unfortunately I do not have the knowledge of the Template code to find out if it really is a bug - I have checked the split function in Stash.pm and this is returning an array correctly and this is about as far as I can go. If anyone can see something really daft in this code, let me know.
If I try to build an array called mylist like this (and I might want to do this if mylist has already got some elements on it that I want to push on)
[%- mylist = [] -%]
[%- counter = 0 -%]
[%- list_string = 'element1;element2;element3' -%]
[%- FOREACH val = list_string.split(';') -%]
data[[% val %]] [[% counter %]]
[% mylist.$counter = val -%]
[%- counter = counter + 1 -%]
[% END -%]
I get the following output
data[element1] [0]
data[element2] [1]
data[element3] [2]
- which is what I would expect, but if I now look at the array it looks like this:
[% FOREACH element = mylist -%]
[[% element %]]
[% END -%]
--output:
[element3]
[element3]
[element3]
And Data::Dumper shows it to look like this:
$VAR1 = [
'element3',
${\$VAR1->[0]},
${\$VAR1->[0]}
];
I can, however, create an array correctly like this...
[% mylist_too = list_string.split(';') -%]
If anyone can see anything wrong in the code, it would be much appreciated.
Thanks
Colin
