You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Todd White <tm...@merit.edu> on 2007/09/26 15:05:58 UTC
RE: $cnt doesn't work for me as advertised (fwd)
I'm wondering if anyone on this list would have any knowledge regarding
the following Embperl question?
Is anyone aware of a bug I may have encountered?
Thanks.
---------- Forwarded message ----------
Date: Wed, 26 Sep 2007 08:06:01 -0400 (EDT)
From: Todd White <tm...@merit.edu>
To: embperl@perl.apache.org
Subject: RE: $cnt doesn't work for me as advertised
Is anyone successfully using the $cnt and $maxcol variables?
On Tue, 25 Sep 2007, Todd White wrote:
> I'm expecting three rows of three columns, like so:
>
> A B C
> D E F
> G
>
> All I am getting is one row of one column.
>
> A
>
>
> --Todd
>
>
> On Tue, 25 Sep 2007, Tom Briles wrote:
>
> > Looks correct to me. What are you expecting?
> >
> > - Tom
> >
> > > -----Original Message-----
> > > From: Todd White [mailto:tmwhite@merit.edu]
> > > Sent: Tuesday, September 25, 2007 3:50 PM
> > > To: embperl@perl.apache.org
> > > Subject: $cnt doesn't work for me as advertised
> > >
> > >
> > > The variable $cnt doesn't seem to work for me. Am I doing something
> > > wrong?
> > >
> > > Here's my code:
> > > ##########################################################
> > > <html>
> > > <head>
> > > <title>$cnt test</title>
> > > </head>
> > > <body>
> > >
> > > [- $maxcol = 3; -]
> > > [+ $maxcol +]<p>
> > >
> > > [- @test_arr = ('A', 'B', 'C', 'D', 'E', 'F', 'G'); -]
> > >
> > > <table>
> > > <tr>
> > > <td>[+ $test_arr[$cnt] +]</td>
> > > </tr>
> > > </table>
> > >
> > > </body>
> > > </html>
> > > ###########################################################
> > >
> > > You can run this here:
> > >
> > > http://www.merit.edu/~tmwhite/test/cnt.epl
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > > For additional commands, e-mail: embperl-help@perl.apache.org
> > >
> > >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > For additional commands, e-mail: embperl-help@perl.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
RE: Re: $cnt doesn't work for me as advertised
Posted by Todd White <tm...@merit.edu>.
Thank you, Gerald!
That work-around works perfectly!
Here is the link to prove it:
http://www.merit.edu/~tmwhite/test/cnt.epl
And here is the updated code that now works exactly as I need:
###############################################################
<html>
<head>
<title>$cnt test</title>
</head>
<body>
[- $maxcol = 3; -]
[+ $maxcol +]<p>
[- @test_arr = ('A', 'B', 'C', 'D', 'E', 'F', 'G'); -]
<table>
<tr>
<td>[+ $test_arr[$row*$maxcol+$col] +]</td>
</tr>
</table>
</body>
</html>
###############################################################
Thank you.
--Todd
On Sat, 29 Sep 2007, Gerald Richter - ECOS GmbH wrote:
> Hi,
>
> $cnt is not (yet) implement in Embperl 2.x (it was in 1.x).
> Documentation is a little bit out of date on this.
>
> It should work to use
>
> [+ $arr[$row*$maxcol+$col] +]
>
> Gerald
>
>
> ------------------------------------------------------------------------
> Besuchen Sie unseren Messestand auf der SYSTEMS vom 23. - 26.10. in
> München, Halle B3, Stand 425 www.ecos.de/messen-events/systems-2007.html
> ------------------------------------------------------------------------
> Gerald Richter ECOS electronic communication services GmbH
> ******************* SECURING YOUR NETWORK ********************
>
> 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
>
> Sitz der Gesellschaft: Dienheim; AG Mainz HRB 6889; GF: W.Heck,G.Richter
> ------------------------------------------------------------------------
>
>
>
> > -----Original Message-----
> > From: Todd White [mailto:tmwhite@merit.edu]
> > Sent: Thursday, September 27, 2007 2:23 PM
> > To: Ben Kim
> > Cc: embperl@perl.apache.org
> > Subject: Re: $cnt doesn't work for me as advertised
> >
> > I shouldn't have to use $row and $col. And I shouldn't have
> > to be working with an array of an array.
> >
> > --Todd
> >
> >
> > On Wed, 26 Sep 2007, Ben Kim wrote:
> >
> > > On Wed, 26 Sep 2007, Todd White wrote:
> > >
> > > I think the $cnt does not work.
> > >
> > > You need to use $row and $col. I think it assumes array of array
> > > (perldoc
> > > perllol) for $col or $maxcol to work.
> > >
> > > [-
> > > @test_arr = (['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H'] ); -]
> > > <table> <tr>
> > > <td>[+ $test_arr[$row][$col] +]</td> </tr> </table>
> > >
> > > ABC
> > > DEF
> > > GH
> > >
> > > If you set $maxcol = 2, then it will be AB DE GH
> > >
> > > I guess even if $cnt is not broken, it will not work for 2
> > dimensional arrays.
> > > Please correct me if I'm wrong.
> > >
> > >
> > > Regards,
> > >
> > > Ben K.
> > > Developer
> > > http://benix.tamu.edu
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > For additional commands, e-mail: embperl-help@perl.apache.org
> >
> >
> > ** Virus checked by BB-5000 Mailfilter **
> > !DSPAM:416,46fba258126381152355010!
> >
> >
>
> ** Virus checked by BB-5000 Mailfilter **
>
RE: Re: $cnt doesn't work for me as advertised
Posted by Gerald Richter - ECOS GmbH <ri...@ecos.de>.
Hi,
$cnt is not (yet) implement in Embperl 2.x (it was in 1.x).
Documentation is a little bit out of date on this.
It should work to use
[+ $arr[$row*$maxcol+$col] +]
Gerald
------------------------------------------------------------------------
Besuchen Sie unseren Messestand auf der SYSTEMS vom 23. - 26.10. in
München, Halle B3, Stand 425 www.ecos.de/messen-events/systems-2007.html
------------------------------------------------------------------------
Gerald Richter ECOS electronic communication services GmbH
******************* SECURING YOUR NETWORK ********************
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
Sitz der Gesellschaft: Dienheim; AG Mainz HRB 6889; GF: W.Heck,G.Richter
------------------------------------------------------------------------
> -----Original Message-----
> From: Todd White [mailto:tmwhite@merit.edu]
> Sent: Thursday, September 27, 2007 2:23 PM
> To: Ben Kim
> Cc: embperl@perl.apache.org
> Subject: Re: $cnt doesn't work for me as advertised
>
> I shouldn't have to use $row and $col. And I shouldn't have
> to be working with an array of an array.
>
> --Todd
>
>
> On Wed, 26 Sep 2007, Ben Kim wrote:
>
> > On Wed, 26 Sep 2007, Todd White wrote:
> >
> > I think the $cnt does not work.
> >
> > You need to use $row and $col. I think it assumes array of array
> > (perldoc
> > perllol) for $col or $maxcol to work.
> >
> > [-
> > @test_arr = (['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H'] ); -]
> > <table> <tr>
> > <td>[+ $test_arr[$row][$col] +]</td> </tr> </table>
> >
> > ABC
> > DEF
> > GH
> >
> > If you set $maxcol = 2, then it will be AB DE GH
> >
> > I guess even if $cnt is not broken, it will not work for 2
> dimensional arrays.
> > Please correct me if I'm wrong.
> >
> >
> > Regards,
> >
> > Ben K.
> > Developer
> > http://benix.tamu.edu
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
> ** Virus checked by BB-5000 Mailfilter **
> !DSPAM:416,46fba258126381152355010!
>
>
** Virus checked by BB-5000 Mailfilter **
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: $cnt doesn't work for me as advertised
Posted by Todd White <tm...@merit.edu>.
I shouldn't have to use $row and $col. And I shouldn't have to be working
with an array of an array.
--Todd
On Wed, 26 Sep 2007, Ben Kim wrote:
> On Wed, 26 Sep 2007, Todd White wrote:
>
> I think the $cnt does not work.
>
> You need to use $row and $col. I think it assumes array of array (perldoc
> perllol) for $col or $maxcol to work.
>
> [-
> @test_arr = (['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H'] );
> -]
> <table>
> <tr>
> <td>[+ $test_arr[$row][$col] +]</td>
> </tr>
> </table>
>
> ABC
> DEF
> GH
>
> If you set $maxcol = 2, then it will be
> AB
> DE
> GH
>
> I guess even if $cnt is not broken, it will not work for 2 dimensional arrays.
> Please correct me if I'm wrong.
>
>
> Regards,
>
> Ben K.
> Developer
> http://benix.tamu.edu
>
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: $cnt doesn't work for me as advertised
Posted by Ben Kim <bk...@tamu.edu>.
On Wed, 26 Sep 2007, Todd White wrote:
I think the $cnt does not work.
You need to use $row and $col. I think it assumes array of array (perldoc
perllol) for $col or $maxcol to work.
[-
@test_arr = (['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H'] );
-]
<table>
<tr>
<td>[+ $test_arr[$row][$col] +]</td>
</tr>
</table>
ABC
DEF
GH
If you set $maxcol = 2, then it will be
AB
DE
GH
I guess even if $cnt is not broken, it will not work for 2 dimensional
arrays. Please correct me if I'm wrong.
Regards,
Ben K.
Developer
http://benix.tamu.edu
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: $cnt doesn't work for me as advertised (fwd)
Posted by Todd White <tm...@merit.edu>.
That's part of the "magic" of this variable. Explicit looping is not
required.
http://perl.apache.org/embperl/pod/doc/Embperl.-page-3-.htm#sect_8
#############################################################################
Embperl can generate dynamic tables (one- or two-dimensional). You only
need to specify one row or column.
Embperl generates as many rows or columns as necessary. This is done by
using the magic variables $row, $col, and $cnt. If you don't use
$row/$col/$cnt within a table, Embperl does nothing and simply passes the
table through.
Embperl checks if any of $row, $col, or $cnt is used. Embperl repeats all
text between <table> and </table>, as long as the expressions in which
$row or $cnt occurs are defined.
Embperl repeats all text between <tr> and </tr>, as long as the
expressions in which $col or $cnt occurs are defined.
See also $tabmode (below) for end-of-table criteria.
Examples: (see eg/x/table.htm for more examples)
[- @k = keys %ENV -]
<TABLE>
<TR>
<TD>[+ $i=$row +]</TD>
<TD>[+ $k[$row] +]</TD>
<TD>[+ $ENV{$k[$i]} +]</TD>
</TR>
</TABLE>
This will show all entries in array @k (which contains the keys from
%ENV), so the whole environment is displayed (as in the while example),
with the first column containing the zero-based index, the second
containing the content of the variable name, and the third the environment
variable's value.
This could be used to display the result of a database query if you have
the result in an array. You may provide as many columns as you need. It is
also possible to call a 'fetch' subroutine in each table row.
#############################################################################
On Wed, 26 Sep 2007, Perrin Harkins wrote:
> On 9/26/07, Todd White <tm...@merit.edu> wrote:
> > I'm wondering if anyone on this list would have any knowledge regarding
> > the following Embperl question?
>
> I don't use Embperl, but it looks like you forgot to write all the
> code to loop through your array and increment $cnt.
>
> - Perrin
>
Re: $cnt doesn't work for me as advertised (fwd)
Posted by Perrin Harkins <pe...@elem.com>.
On 9/26/07, Todd White <tm...@merit.edu> wrote:
> I'm wondering if anyone on this list would have any knowledge regarding
> the following Embperl question?
I don't use Embperl, but it looks like you forgot to write all the
code to loop through your array and increment $cnt.
- Perrin