Re: [htmltmpl] How to manipulate rows in returned resultset
Brought to you by:
samtregar
From: Sam T. <sa...@tr...> - 2006-03-13 22:47:42
|
On Mon, 13 Mar 2006, Kapoor, Nishikant wrote: > Is there a way I can continue to use the 'single' assignment, and > still achieve this objective? You seem to have the right idea here: > #BUT, if I need to bold the 'search text', I need to iterate through the loop > my @loopData=(); > foreach my $rec (@{$data}) { > my %loopRow; > $rec->{title} =~ s/(\b$searchText\b)/<b>$1<\/b>/ig; > $loopRow{title} = $rec->{title}; > push @loopData, \%loopRow; > } > $template->param(myLoopVar => \@loopData); If you're dying to do it in one statement I suppose you could do: $template->param(myLoopVar => [ map { $_->{title} =~ s!\b($searchText)\b!<b>$1</b>!ig; $_ } @$data ]); I don't exactly consider that an improvement, personally. -sam |