perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luiz Fernando B. Ribeiro" <l...@engenhosolucoes.com.br>
Subject Re: Simple table problem
Date Wed, 03 Dec 2003 10:57:29 GMT
On 03 Dec 2003 17:15:57 +1100, Pete Moran <pete@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


Mime
View raw message