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 <t...@audioboundary.com> To: Rajeev Prasad <rp.ne...@yahoo.com> Cc: perl_TT <templates@template-toolkit.org> 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 _______________________________________________ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates