You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Richard Schilling <rs...@nationalinformatics.net> on 2003/09/12 00:35:17 UTC

creative use of $row, $col in tables

Just wanted to share this technique and see how others achieve the same 
thing. Anyone else doing something similar or have a better trick?


Here's some code that creates a nice, compact table definition around a 
set of tuples returned from a database (in this case gnucash).

[- $oldmaxcol = $maxcol;
    $maxcol = 3;
-]

<TABLE border="1">

[- # read in a record from the gnucash database using the Pg interface
    @accountinfo=$gnucash_accounts->fetchrow;
-]

<TR><TD>[+ $accountinfo[$col+$row-$row] +]</TD></TR>

</TABLE>

[- $maxcol = $oldmaxcol; -]

=======================================

I'm using $row-$row ($row minus $row equals zero) in the arrary 
reference just to get Embperl to see the $row reference in a statement 
and stop outputting the table when no more records are read from the 
database ( $accountinfo[$col+$row-$row], which is the same as 
$accountinfo[$col] will be undefined if a record is not read).

The purpose of the code is to minimize the lines of code to get the 
table generated properly.


Thanks!

Ricahrd Schilling

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