Re: tt hash values not printing....

Tom Molesworth <tom-UE50auxAeIt4LjgWlUEQQwC/[email protected]> Wed, 31 Oct 2012 00:31:55 +0000
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <[email protected]>
On 31/10/12 00:19, Rajeev Prasad wrote:
> hi Tom,
>
> I just solved (found issue) with this.
>
> I changed the way i was building the hash value: and then it worked fine.
>
> $my_hash->{$index} = [$val1, $val2];
>
> Also i looked and found nsort which resolved the other prob too.
>
> but i have a new problem now. I am trying to break a long string (val2) on the first html break character (<br>) I am using this logic but it is not working. it seems my regex is wrong. i have tried many things. but it does not owrk. I get nothing for matches.1 can you suggest ?
>
>      [% IF (matches = myhash.$index.1.match('(.*<br>)(.*$)')) %]
>      <td><tt>[%- matches.0 -%]</tt><tt style="color:green;">[%- matches.1 -%]</tt></td>
>      [% ELSE %]
>      <td><tt>[%- myhash.$index.1 -%]</tt></td>
>      [% END %]
>
>

vmethods again, look for split.

perl -MTemplate -le'Template->new->process(\q{[% FOR section IN 
text.split("<br>") %]=> [% section _ "\n" %][% END %]}, { text => 
q{sample<br>text<br>here} })'

cheers,

Tom