You aren't using split wrong, you are using "val" wrong. =) You are
suffering from the classic error of putting the same reference into
an array with each pass through your FOREACH loop.

I'd recommend you do:
[% mylist = list_string.split(';') -%]
[% FOREACH val = mylist %]
  data[[% val %]] [[% loop.count %]]
[% END -%]

--mark

> 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.
>
> [%- FOREACH val = list_string.split(';') -%] 
>         data[[% val %]] [[% counter %]] 
>         [% mylist.$counter = val -%] 
>         [%- counter = counter + 1 -%] 
> [% END -%] 
>
> 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. 


Reply via email to