RE: How to manipulate rows in returned resultset
"Kapoor, Nishikant" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.html-template |
|---|---|
| Message-ID | <B4448B75FF74124ABB5793D8BFBEEA3901C13DFA@exccpgo04.corp.xcelenergy.com> |
> #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 ]);
[Nishi]
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
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642