Re: tt hash values not printing....
Rajeev Prasad <rp.neuli-/[email protected]> Tue, 30 Oct 2012 17:49:53 -0700 (PDT)
| Newsgroups | gmane.comp.lang.perl.modules.template-toolkit |
|---|---|
| Message-ID | <[email protected]> |
with split I will have to join back the pieces.
I do not know how many <br> will be there.
I only want to separate the string on first <br>
so only two pieces to work with one before <br> and another after <br>
following NOT working....
myhash.$index.1.remove('<br>.*$')
myhash.$index.1.replace('<br>.*$','')
It just results in full string. as if $ is not working in above....
----- Original Message -----
From: Tom Molesworth <tom-UE50auxAeIt4LjgWlUEQQwC/[email protected]>
To: Rajeev Prasad <rp.neuli-/[email protected]>
Cc: perl_TT <[email protected]>
Sent: Tuesday, October 30, 2012 7:31 PM
Subject: Re: [Templates] tt hash values not printing....
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