Re: TMPL_LOOP limit or count

"David A. Bandel" <[email protected]> Fri, 29 Apr 2011 20:04:08 -0500
Newsgroups gmane.comp.lang.perl.modules.html-template
Message-ID <[email protected]>
On Fri, Apr 29, 2011 at 16:37, Michael Peters <[email protected]> wrote:
> On 04/29/2011 05:28 PM, David A. Bandel wrote:
>
>> my @calloutdata;
>> foreach $callskey ( sort {$callnum{$b}<=3D> =A0$callnum{$a}} keys %calln=
um){
>> =A0 =A0 my %outbound;
>> =A0 =A0 $outbound{EXTENNUMCALLED} =A0=3D $callskey;
>> =A0 =A0 $outbound{TIMESCALLED} =A0 =A0 =A0=3D $callnum{$callskey};
>> =A0 =A0 push( @calloutdata, \%outbound );
>> }
>>
>> =A0 =A0 =A0 =A0 $template->param( OUTBOUNDS =3D> =A0\@calloutdata );
>>
>> The calloutdata array winds up to be about 200 lines long. =A0Any way to
>> have the TMPL_LOOP stop output after 15 or so table lines?
>
> Well, the first thing I'd do is suggest that if possible you just don't p=
ut
> all 200 things into the loop. That would save on your processing if you
> didn't have to create the big loop to begin with.

Unfortunately, in order to do what I'm doing (you haven't seen the
code that comes before), I need all the values all at once or the sort
on the value of the key/value pair doesn't work.


>
> But if you needed them in the loop in some places but didn't want to disp=
lay
> them in others, you can use the __counter__ loop context var combined with
> HTML::Template::Expr.

It's an idea.  But hoping to keep it simple.

>
> <tmpl_loop outbounds>
> =A0<tmpl_if expr=3D"__counter__ <=3D 15">
> =A0 =A0...
> =A0</tmpl_if>
> </tmpl_loop>
>
>> Nothing in the docs suggests a way to do this (or am I missing
>> something?).
>
> It's not possible with just HTML::Template, but HTML::Template::Expr shou=
ld
> help you get there.
>
> --
> Michael Peters
> Plus Three, LP
>

Will keep this in mind.

Thanx,

David A. Bandel
-- =

Focus on the dream, not the competition.
=A0 =A0 =A0 =A0 =A0 =A0 - Nemesis Air Racing Team motto
Visit my web page at: http://david.bandel.us/

---------------------------------------------------------------------------=
---
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network =

management toolset available today.  Delivers lowest initial =

acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd