Re: split question

Johan Vromans <[email protected]> Sun, 17 Aug 2014 22:58:18 +0200
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <[email protected]>
Jean-Michel Caricand <[email protected]> writes:

> Hello,
>
> I have a little question with split. I want to split my string
> variable on "."
>
> Example :
>
>
> data.className contents = "A.b.C";
>
> [% BLOCK viewController %]
> [% items = data.className.split('\.');
> %]
>
> [% items.last %]
>
> That doesn't work. With Perl, I can use this :
>
> @items = split(/\./, data->{className});
>
> but that doesn't work with TT2.
>
> Any idea ?

This works:

[% x = 'a.b.c'; x.split('\.').join('|') %]

it outputs a|b|c 

Are you sure you did set the value of data.className correctly?

-- Johan