You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Pete Moran <pe...@forloop.co.uk> on 2003/12/03 07:15:57 UTC

Simple table problem

I know this is a really simple problem - and can be fixed using if
statements etc - but wanted to know if there was a standard way of doing
this.

Simply say I have a array

@array = qw/1 2 3 4 5 6 7 8 9 10/;

And I want to create a dynamic table of this data - BUT I want to have a
fixed column length (in this case 4).  The end table should look like

<table>
  <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    <td>4</td>
  </tr>
  <tr>
    <td>5</td>
    <td>6</td>
    <td>7</td>
    <td>8</td>
  </tr>
  <tr>
    <td>9</td>
    <td>10</td>
  </tr>
</table>

Using the dynamic table syntax and the associated magic variables - can
this be achieved - or do I have to add some custom code ?  Have checked
out various examples and searched the mailing list but seems either it
cant be done this way or I am yet again missing the point.



Regards



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Simple table problem

Posted by Gerald Richter <ri...@ecos.de>.
>
> This can be done with $maxcol and $cnt, I have not tested but try
> this:
>

This works with 1.3...

>
> [-
> @array = qw/1 2 3 4 5 6 7 8 9 10/;
> $maxcol = 4;
> -]
> <table>
>     <tr>
>       <td>[+ $array[$cnt] +]</td>
>     </tr>
> </table>

2.0 doesn't support $cnt yet, here write instead the following to get the
same result

       <td>[+ $array[$col + ($row * $maxcnt)] +]</td>

Gerald


--------------------------------------------------------------
Gerald Richter     ecos electronic communication services gmbh
IT-Securitylösungen * dynamische Webapplikationen * Consulting

Post:       Tulpenstrasse 5          D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de          Voice:   +49 6133 939-122
WWW:        http://www.ecos.de/      Fax:     +49 6133 939-333
--------------------------------------------------------------
|
|   ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
|
+-------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: Simple table problem

Posted by "Luiz Fernando B. Ribeiro" <lu...@engenhosolucoes.com.br>.
On 03 Dec 2003 17:15:57 +1100, Pete Moran <pe...@forloop.co.uk> wrote:

> I know this is a really simple problem - and can be fixed using if
> statements etc - but wanted to know if there was a standard way of doing
> this.
>
> Simply say I have a array
>
> @array = qw/1 2 3 4 5 6 7 8 9 10/;
>
> And I want to create a dynamic table of this data - BUT I want to have a
> fixed column length (in this case 4).  The end table should look like
>
> <table>
>   <tr>
>     <td>1</td>
>     <td>2</td>
>     <td>3</td>
>     <td>4</td>
>   </tr>
>   <tr>
>     <td>5</td>
>     <td>6</td>
>     <td>7</td>
>     <td>8</td>
>   </tr>
>   <tr>
>     <td>9</td>
>     <td>10</td>
>   </tr>
> </table>

This can be done with $maxcol and $cnt, I have not tested but try this:


[-
@array = qw/1 2 3 4 5 6 7 8 9 10/;
$maxcol = 4;
-]
<table>
    <tr>
      <td>[+ $array[$cnt] +]</td>
    </tr>
</table>

-- 
Luiz Fernando B. Ribeiro
Engenho Soluções para a Internet

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org