RE: [htmltmpl] How to manipulate rows in returned resultset
Brought to you by:
samtregar
From: Kapoor, N. <nis...@xc...> - 2006-03-15 15:23:04
|
> #BUT, if I need to bold the 'search text', I need to iterate through = the loop > my @loopData=3D(); > foreach my $rec (@{$data}) { > my %loopRow; > $rec->{title} =3D~ s/(\b$searchText\b)/<b>$1<\/b>/ig; > $loopRow{title} =3D $rec->{title}; > push @loopData, \%loopRow; > } > $template->param(myLoopVar =3D> \@loopData); If you're dying to do it in one statement I suppose you could do: $template->param(myLoopVar =3D> [ map { $_->{title} =3D~ s!\b($searchText)\b!<b>$1</b>!ig; $_ } @$data ]); [Nishi]=20 The 'single' statement lets me assign any and all fields in one go - = without having to worry about individual fields. I was hoping if somehow = I could populate @{$data} with the 'replaced' text, that would do it. = Also, there are cases when the resultset contains different fields based = on different conditions it was called with. So, access to individual = fields is not always available. Not a big issue, but just wanted to run = it by the group. Thanks for the prompt response. Nishi |