Re: split question

breno <[email protected]> Sun, 17 Aug 2014 18:09:13 -0300
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <CAHS-WQbuY4v_TGjh+OdK8aRboNqqjePKF7w8zxFAe0o2+_aHOQ@mail.gmail.com>
On Sun, Aug 17, 2014 at 4:23 PM, Jean-Michel Caricand
<[email protected]> wrote:
> 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 ?
>

Try seeing the content of your variable before the split to see if
it's really there. For instance:

[% USE Dumper; Dumper.dump(data.className) %]

Cheers!